Method and apparatus for data permutation/division and recording medium with data permutation/division program recorded thereon

ABSTRACT

In a method for permuting and dividing 16 pieces of k-bit data held in 4k-bit long registers T 0 . T 1 , T 2  and T 3 , k being an integer, the data of each register T i  is ANDed with a desired one of mask data (00ffff00), (ff0000ff), (0000ffff) and (ffff0000), and such ANDs are ORed to obtain desired permuted data.

BACKGROUND OF THE INVENTION

The present invention relates to a method and apparatus for efficient implementation of data permutation and division processing in the field of cryptography and a recording medium with a data permutation/division program recorded thereon.

Data encryption is intended to conceal data. Data encryption techniques fall into a common key cryptosystem and a public key cryptosystem.

The public key cryptosystem uses different keys for data encryption and for decryption; usually, the encryption key is made public and the decryption key is held by a user in secrecy. It is believed that the description key could not be derived from the encryption key within a practical amount of time even with modern mathematical theories and the computing power of the present-day computer.

On the other hand, the common key cryptosystem uses the same key for data encryption and decryption. To implement a fast and secure common key cipher, there is proposed a block encipherment scheme that divides data to be enciphered into blocks of an appropriate length and enciphers them one by one. Many of the block ciphers have a structure called a Feistel network. With this structure, an input of 2n bits is divided to right and left pieces of n-bit data, a function f is operated on the right n-bit data, then its output is exclusive ORed with the left n-bit data, then the right and left pieces of data are swapped, and the same operation is repeated. This structure is shown in, “Bruce Schneier, Applied Cryptography, 2^(nd) edition, John-Wiley and Sons, p347, 1996.”

The common key cryptosystem is smaller in computational complexity than the public key cryptosystem, and the amount of data that can be encrypted per unit time in the former cryptosystem is tens to hundreds of times larger than in the latter cryptosystem. For this reason, there are tendencies to use the common key cryptosystem when fast encryption processing is necessary.

The common key cryptosystem is required to have security against cryptanalysis as well as the above-mentioned high-speed performance. In recent years there have been proposed several methods of cryptanalysis for common key encryption algorithms. It is necessary, therefore, that a common key encryption algorithm to be newly developed be always secure against such cryptanalysis methods. These cryptanalysis methods are described, for example, in “Bruce Schneier, Applied Cryptography, 2nd edition, John-Wiley and Sons, pp.285-293, 1996.”

There have also been studied schemes that would not allow easy application of the cryptanalysis methods, and it can be expected that such preventive schemes will increase the security of the common key encryption algorithm. According to one of such preventive schemes, a value of some kind available from an encryption key is exclusive ORed with input and output data so as to protect the input and output data for the basic encryption, algorithm from an attacker. This scheme is described in “Bruce Schneier, Applied Cryptography, 2nd edition, John-Wiley and Sons, pp.366-367, 1996.” Many of common key encryption algorithms proposed in recent years are designed using this scheme.

With the above scheme, the input data exclusive ORed with the value of some kind available from the encryption key is used as input data of the basic encryption algorithm. In the case of using the afore-mentioned Feistel network, the input data needs to be divided to right and left data. Some of recently developed common key encryption algorithms are intended to provide increased security not only by dividing the input data to right and left but also by dividing the input data to right and left even after permutation. An example of such algorithms is an E2 cipher (Masayuki KANDA, et al., “A New 128-bit Block Cipher E2,” Technical Report of IEICE, ISEC98-12 (hereinafter referred to simply as literature E2). In the E2 algorithm, a permutation processing called a BP function is defined and then the input data is divided to right and left for input into the Feistel network.

FIG. 1 depicts a basic configuration of an E2 cryptographic device, in which no key scheduling part is shown for brevity. The E2 cryptographic device is made up of an initial transformation part 10, twelve round processing stages RND₁ to RND₁₂, and a final transformation part 30. The size of each key is, for instance, 128-bit. The initial transformation part 10 comprises: an XOR operation part 11 that exclusive ORs an input plaintext M of, for example, 128 bits with a subkey k₁₃; a multiplication part 12 that calculates the product of the output from the XOR operation part 11 and a subkey k₁₄; and a byte permutation part (hereinafter referred to as a BP function part) 13 that performs byte permutation of the multiplied output from the multiplication part 12. To increase the operation efficiency, setting the computation size of a CPU of the computer used, for example, at 32 bits, the operation is carried out for each of four 32-bit subblocks divided from the 128-bit data.

The initial transformation part (hereinafter referred to as an IT function part) 10 performs the following operation for an input X=M using the subkeys k₁₃ and k₁₄.

A=IT(X, k ₁₃ , k ₁₄)  (1)

More specifically, letting

X=(x ₁ , x ₂ , x ₃ , x ₄)

Y=(y ₁ , y ₂ , y ₃ , y ₄)

Z=(z ₁ , z ₂ , z ₄ , z ₄)

the following operation is performed by the XOR operation part 11 and the multiplication part 12.

Z=(X⊕k ₁₃){circle around (×)}k ₁₄ =Y{circle around (×)}k ₁₄  (2)

In the above, if k₁₄=(K₁, K₂, K₃, K₄), the multiplication Y{circle around (×)}k₁₄ by the multiplication part 12 is performed as follows:

z _(i) =y _(i)(K _(i)1_((hex)))mod 2³² for i=1,2,3,4  (3)

The operation symbol ab represents the OR of a and b for every corresponding bit. Setting

(z _(i) ⁽¹⁾ , z _(i) ⁽²⁾ , z _(i) ⁽³⁾ , z _(i) ⁽⁴⁾)=z _(i) for i=1,2,3,4  (4)

Z′=(z ₁ ′, z ₂ ′, z ₃ ′, z ₄′)

The operation processing of the BP function part 13 is expressed by the following equation:

z _(i)′=(z′ _(i) ⁽¹⁾ , z′ _(i+1) ⁽²⁾ , z′ _(i+2) ⁽³⁾ , z′ _(i+3) ⁽⁴⁾), i=1,2,3,4,  (5)

where

z′ _(i+4) ^((j)) =z′ _(i) ^((j)) , j=1,2,3,4  (6)

where i represents the subblock number for each 32 bits and j the data number of each byte in the subblock. In FIG. 3 there are shown permutations expressed by Eqs. (5) and (6). The four bytes of each piece of data z₁, z₂, z₃ and z₄ are distributed to four different output data groups.

The output from the byte permutation part (that is, the BP function part) 13 is divided to right data R₀ and left data L₀, which are provided to the round processing stage RND₁. The i-th round processing stage RND_(i) performs substitution-permutation processing of right data R_(i−1) in a round function part 22 by using a subkey k_(i), and provides the substitution result to an XOR operation part 21, wherein it is exclusive ORed with left data L_(i−1) fed thereto. The right data R_(i−1) input to the i-th stage and the output from the XOR operation part 21 are exchanged in position, and they are provided as left data L_(i) and right data R_(i) to the next round processing stage RND_(i+1).

This is expressed as follows:

R _(i) =L _(i−1) ⊕F(R _(i−1) , k _(i))  (7)

L _(i) =R _(i−1) , i=1, 2, . . . , 12  (8)

Each round function part 22 comprises, as depicted in FIG. 2, eight XOR operation parts 22X1, eight S-boxes (S function) 22S1, a linear permutation part (a P function part) 22P, eight XOR operation parts 22X2, and eight S-boxes 22S2. 64-bit right data R is input to the i-th round processing stage RND_(i). In the round function part 22, setting the input R_(i−1)

R _(i−1)=(r ₁ , r ₂ , r ₃ , r ₄ , r ₅ , r ₆ , r ₇ , r8)

k _(i)=(K ⁽¹⁾ , K ⁽²⁾)=(K ₁ ⁽¹⁾ , K ₂ ⁽¹⁾ , . . . , K ₈ ⁽¹⁾ , K ₁ ⁽²⁾ , K ₂ ⁽²⁾ , . . . , K ₈ ⁽²⁾)

the outputs from the S-boxes 22S1 is given by the following equation:

(u ₁ , u ₂ , . . . , u ₈)=(s(r ₁ ⊕K ₁ ⁽¹⁾),s(r ₂ ⊕K ₂ ⁽¹⁾), . . . , s(r ₈ ⊕K ₈ ⁽¹⁾))  (9)

The output from the linear permutation part 22P can be expressed as follows:

u′ ₁ =u ₂ ⊕u ₃ ⊕u ₄ ⊕u ₅ ⊕u ₆ ⊕u ₇

u′ ₂ =u ₁ ⊕u ₃ ⊕u ₄ ⊕u ₆ ⊕u ₇ ⊕u ₈

u′ ₃ =u ₁ ⊕u ₂ ⊕u ₄ ⊕u ₅ ⊕u ₇ ⊕u ₈

u′ ₄ =u ₁ ⊕u ₂ ⊕u ₃ ⊕u ₅ ⊕u ₆ ⊕u ₈

u′ ₅ =u ₁ ⊕u ₂ ⊕u ₄ ⊕u ₅ ⊕u ₆

u′ ₆ =u ₁ ⊕u ₂ ⊕u ₃ ⊕u ₆ ⊕u ₇

u′ ₇ =u ₂ ⊕u ₃ ⊕u ₄ ⊕u ₇ ⊕u ₈

u′ ₈ =u ₁ ⊕u ₃ ⊕u ₄ ⊕u ₅ ⊕u ₈  (10)

The outputs from the S-boxes 22S2 are expressed by the following equation:

(v ₁ ,v ₂ ,v ₃ ,v ₄ ,v ₅ ,v ₆ ,v ₇ ,v ₈)=(s(u′ ₁ ⊕K ₁ ⁽²⁾), s(u′ ₂ ⊕K ₂ ⁽²⁾), . . . , s(u′ ₈ ⊕K ₈ ⁽²⁾))  (11)

These outputs are subjected to byte rotation and then output from the round function part 22.

In the case of FIG. 1, twelve such round processing stages are cascade-connected, and left and right data L₁₂ and R₁₂ output from the 12-th round processing part RND₁₂ are concatenated into 128-bit data, which is fed to a BP⁻¹ function part 31 of the final transformation part 30.

The final transformation part 30 obtains, as a ciphertext X=C, X=FT(Z′, k₁₅, k₁₆) from the input thereto Z′=(z₁′, z₂′, z₃′, z₄′) and keys k₁₅, k₁₆. More specifically, the BP⁻¹ function part 31 performs inverse processing of the BP function part 13 by the following equation to obtain the output Z.

(z′ _(i) ⁽¹⁾ , z′ _(i) ⁽²⁾ , z′ _(i) ⁽³⁾ , z′ _(i) ⁽⁴⁾)=z′ _(i) , i=1, 2, 3, 4

z _(i)=(z′ _(i) ⁽¹⁾ , z′ _(i−1) ⁽²⁾ , z′ _(i−2) ⁽³⁾ , z′ _(i−3) ⁽⁴⁾)i=1,2,3,4  (12)

 where z′ _(i−4) ^((j)) =z′ _(i) ^((j)) j=1,2,3,4  (13)

Z=(z ₁ , z ₂ , z ₃ , z ₄)

The output Z is provided to a division part 32, which performs the division of the following equation using a subkey k₁₅=(K₁,K₂,K₃,K₄).

y _(i) =z _(i)(K _(i)1_((hex)))⁻¹ mod 2³² , i=1,2,3,4  (14)

A variable in Eq. (14) is z_(i) alone. Hence, it is possible to provide increased efficiency of calculation to precalculate and prestore the value of an inverse element G_(i)=(K_(i)1_((hex)))⁻¹ mod 2³² in a memory, since the stored value can be used to calculate y_(i)=z_(i)G_(i) mod 2³² for each input data z_(i). The calculation result Y=(y₁,y₂,y₃,y₄) is exclusive ORed with a subkey k₁₆in an XOR operation part 33 by the following equation, and the resulting output X is provided as the ciphertext C.

C=X=Y⊕k ₁₆  (15)

FIG. 3 depicts the input/output relationship by the byte permutation using the BP functions expressed by Eqs. (5) and (6). As shown, the four pieces of 4-byte data z₁, z₂, z₃ and z₄ are rearranged on a bytewise basis to obtain the four pieces of 4-byte data z₁′, z₂′, z₃′ and z₄′. Conventionally, this byte permutation is implemented by performing the operation expressed by the following equation:

z ₁′=(z ₁ff000000)(z ₂00ff0000)(z ₃0000ff00)(z ₄000000ff)

z ₂′=(z ₂ ff000000)(z ₃00ff0000)(z ₄0000ff00)(z ₁000000ff)

z ₃′=(z ₃ ff000000)(z ₄00ff0000)(z ₁0000ff00)(z ₂000000ff)

z ₄′=(z ₄ ff000000)(z ₁00ff0000)(z ₂0000ff00)(z ₃000000ff)  (16)

where the symbol represents the AND for each bit and the symbol the OR for each bit and “f” and “0” are hexadecimal values. This operation is performed as depicted in FIG. 4. For the sake of brevity, the entire data Z=z_(i) ^((j))(where i=1,2,3,4; j=1,2,3,4) is represented by a sequence of data a₀, a₁, . . . , a₁₅. For example, 4-byte data z₁ of a register RG1 and 4-byte mask data MD1 of a mask register MRG1 are ANDed to obtain z₁ff000000, which is stored in a register RG1′. Then, the AND of data z₂ and mask data MD2, z₂00ff0000, is calculated and is ORed with the data read out of the register RG1′, and the OR thus obtained is overwritten on the register RG1′. By performing the same processing for mask data MD3 and MD4 as well, the data z₁′ is provided in the register RG1′. The same calculation processing as described above is also carried out for the data z₂′, z₃′ and z₄′ by Eq. (16). Thus the byte permutation results are obtained in registers RG1′ to RG4′. In the implementation of this calculation scheme, there have been pointed out such problems as mentioned below. That is, the processing by the BP function is byte-byte permutation processing, but a one-word register built in recent CPUs involves masking and shift operations, and hence it consumes much processing time. And, even if the permutation can be made after the ORs are once copied to a memory, the time for memory access inevitably increases, resulting in the processing time increasing. These problems constitute an obstacle to the realization of high-speed performance of the common key cryptosystem.

In the division part 32 in FIG. 1 a precalculated inverse element can be used. In general, it is possible to utilize, for the execution of an inverse element calculation to modulus N, an extended Euclidian algorithm set forth, for instance, in Okamoto and Ohta, coeditors, “Cipher/Zero Knowledge Proof/Number Theory,” Kyouritsu Shuppan, 1995, pp.120-121. In the case of Eq. (14), however, since the modulus has a special form of ₂ ^(m), the inverse element can efficiently be calculated by the use of a Hensel Lifting method (a natural method of raising the root of a polynomial from mod b^(m) to mod b^(m+1)). In the calculation of the inverse element with software, when m is about one word length, a Zassenhaus's proposed method which is a quadratic version of the Hensel Lifting (H. Zassenhaus, “On Hensel Factorization, I,” Journal of number theory, vol.1, pp.291-311, 1969) is effective because the word multiplication is relatively fast on recent CPUs.

Letting the input be represented by x, the output by y and auxiliary or temporary variables by a and b and letting [x] represent a Gauss symbol (the maximum integer which does not exceed x), the Zassenhaus method provides an algorithm for calculating an inverse y=x⁻¹ mod 2^(m) as given below assuming that the bit position is given 0 as the least significant bit and that the bit lengths of x, y, a and b are m, where m=2^(n)(n≧1):

Step 1: Input x.

Step 2: Initialize y:=1 and b:=[x/2]

Step 3: Do the following for i=0, 1, . . . , n−1

1. Set a as low-order 2^(i) bits of y×(2² ^(i) −(low-order 2^(i) bits of b)).

2. Pad 2^(i)-th to (2^(i+1)−1)-th bits of y with low-order 2^(i) bits of a.

3. Store 2^(i)-th to (2^(n)−2^(i)−1)-th bits of xa+b in b.

Step 4: Output y.

This bit processing is such as shown in FIG. 5, in which the contents of the register having stored therein the output y for state changes of i are represented by binary numbers.

“1” indicates bits whose value is always 1, “.” calculated bits, and “?” unknown bits. In the result with i=2 calculated using i=1, fourth to seventh bits are determined. To arrange data in the fourth to seventh bits will hereinafter be referred to as “padding.”

The configuration of the RSA cipher, which is a typical public key cryptosystem, is described, for example, in the above-mentioned literature “Cipher/Zero Knowledge Proof/Number Theory,” p.220. The RSA cipher requires a power calculation over Z/NZ, that is, what is called a modular exponentiation. For fast execution of this modular exponentiation, it is effective to use the Montgomery modular arithmetic algorithm introduced in the above-mentioned literature on pages 179-181. The execution of the Montgomery modular arithmetic algorithm involves an inverse calculation in mod 2^(m) using m as a natural number.

The above-mentioned Zassenhaus scheme involves bitwise processing such as extraction and padding of low-order 2^(i) bits and, in the case of software implementation, the masking operation increases, and hence efficiency is not so high.

The round function part 22 of the round processing stage depicted in FIG. 2 is formed by a combination of the substitution by the S function part 22S1 and the permutation by the P function part 22P.

The substitution-permutation is a concept of a considerably broad meaning. To meet a demand for software implementation in recent years, there has widely been used the substitution-permutation in the following form: $\begin{matrix} {\begin{bmatrix} y_{1} \\ y_{2} \\ \vdots \\ y_{m} \end{bmatrix} = {P\quad\begin{bmatrix} {s_{1}\left( x_{1} \right)} \\ {s_{2}\left( x_{2} \right)} \\ \vdots \\ {s_{n}\left( x_{n} \right)} \end{bmatrix}}} & (17) \end{matrix}$

In this instance, operations are all performed over the ring R. The permutation is given by $\begin{matrix} {P = \quad \begin{bmatrix} p_{11} & p_{12} & \cdots & p_{1n} \\ p_{21} & p_{22} & \cdots & p_{2n} \\ \vdots & \vdots & ⋰ & \vdots \\ p_{m1} & p_{m2} & \cdots & p_{mn} \end{bmatrix}} & (18) \end{matrix}$

and the substitution is set to s_(j):R→R(j=1, 2, . . . , n). That is, the product of the matrix is considered as permutation.

The substitution-permutation expressed by Eq. (17) is also used in the cipher SHARK that is defined in V. Rijmen, et al. “The Cipher SHARK,” Fast Software Encryption-Third International Workshop, Lecture Notes in Computer Science 1039, pp. 99-111, Springer-Verlag 1996 (hereinafter referred to simply as Literature S). In Literature S there is also described a method in which the following modified equation is used $\begin{matrix} {\quad {{\begin{bmatrix} p_{11} & p_{12} & \cdots & p_{1n} \\ p_{21} & p_{22} & \cdots & p_{2n} \\ \vdots & \vdots & ⋰ & \vdots \\ p_{m1} & p_{m2} & \cdots & p_{mn} \end{bmatrix}\quad\left\lbrack \quad \begin{matrix} {s_{1}\left( x_{1} \right)} \\ {s_{2}\left( x_{2} \right)} \\ \vdots \\ {s_{n}\left( x_{n} \right)} \end{matrix} \right\rbrack} = {{\begin{bmatrix} {p_{11}{s_{1}\left( x_{1} \right)}} \\ {p_{21}{s_{1}\left( x_{1} \right)}} \\ \vdots \\ {p_{m1}{s_{1}\left( x_{1} \right)}} \end{bmatrix} + \begin{bmatrix} {p_{12}{s_{2}\left( x_{2} \right)}} \\ {p_{22}{s_{2}\left( x_{2} \right)}} \\ \vdots \\ {p_{m2}{s_{2}\left( x_{2} \right)}} \end{bmatrix} + \cdots + \begin{bmatrix} {p_{1n}{s_{n}\left( x_{n} \right)}} \\ {p_{2n}{s_{n}\left( x_{n} \right)}} \\ \vdots \\ {p_{mn}{s_{n}\left( x_{n} \right)}} \end{bmatrix}}}}} & (19) \end{matrix}$

and the output value of the function SP_(i) expressed by the following equation (20) is precalculated corresponding to every x_(j) and prestored, for example, in a memory to thereby efficiently calculate Eq. (17). $\begin{matrix} {{S\quad P_{j}\text{:}\quad {RR^{m}}};\quad {{S\quad {P_{j}\left( x_{j} \right)}} = {\begin{bmatrix} {p_{1j}{s_{j}\left( x_{j} \right)}} \\ {p_{2j}{s_{j}\left( x_{j} \right)}} \\ \vdots \\ {p_{mj}{s_{j}\left( x_{j} \right)}} \end{bmatrix}\quad \left( {{j = 1},2,\ldots \quad,n} \right)}}} & (20) \end{matrix}$

In the cipher utilizing the substitution-permutation scheme, there is a case where no permutation is performed at the end of processing but only substitution is used. That is, the following processing is also necessary for cipher implementation. $\begin{matrix} {\begin{bmatrix} y_{1} \\ y_{2} \\ \vdots \\ y_{n} \end{bmatrix} = \begin{bmatrix} {s_{1}\left( x_{1} \right)} \\ {s_{2}\left( x_{2} \right)} \\ \vdots \\ {s_{n}\left( x_{n} \right)} \end{bmatrix}} & (21) \end{matrix}$

When the size of the element in R is smaller than the word length that is the operation unit in the computer used, it is necessary in straightforward implementation that the calculation of individual values of s_(j)(X_(j)) be followed by shifting them to their correct vector positions. In this instance, the necessity for the data position adjustment process can be avoided by Modifying Eq. (21) to $\begin{matrix} {\begin{bmatrix} y_{1} \\ y_{2} \\ \vdots \\ \vdots \\ y_{n} \end{bmatrix} = {\begin{bmatrix} {s_{1}\left( x_{1} \right)} \\ 0 \\ \vdots \\ \vdots \\ 0 \end{bmatrix} + \begin{bmatrix} 0 \\ {s_{2}\left( x_{2} \right)} \\ 0 \\ \vdots \\ 0 \end{bmatrix} + \cdots + \begin{bmatrix} 0 \\ \vdots \\ \vdots \\ 0 \\ {s_{n}\left( x_{n} \right)} \end{bmatrix}}} & (22) \end{matrix}$

as is the case with Eq. (17) and by precalculating a table in which the positions of vector elements have been adjusted so that 0s would be provided except at the j-th position.

The calculation for the substitution and permutation described in Literature S is disadvantageous in that it involves a large number of memory references and requires a large memory capacity.

As described previously, letting the input data be (u₁, u₂, . . . , u₈) and the output data b (u₁′, u₂′, . . . , u₈′), the P function part 22P in the cipher E2 shown in FIG. 2, for instance, performs an operation using the product expressed by the following equation. $\begin{matrix} {{\begin{bmatrix} u_{1}^{\prime} \\ u_{2}^{\prime} \\ u_{3}^{\prime} \\ u_{4}^{\prime} \\ u_{5}^{\prime} \\ u_{6}^{\prime} \\ u_{7}^{\prime} \\ u_{8}^{\prime} \end{bmatrix} = {P\quad\begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ u_{6} \\ u_{7} \\ u_{8} \end{bmatrix}}},\quad {P = \begin{bmatrix} 0 & 1 & 1 & 1 & 1 & 1 & 1 & 0 \\ 1 & 0 & 1 & 1 & 0 & 1 & 1 & 1 \\ 1 & 1 & 0 & 1 & 1 & 0 & 1 & 1 \\ 1 & 1 & 1 & 0 & 1 & 1 & 0 & 1 \\ 1 & 1 & 0 & 1 & 1 & 1 & 0 & 0 \\ 1 & 1 & 1 & 0 & 0 & 1 & 1 & 0 \\ 0 & 1 & 1 & 1 & 0 & 0 & 1 & 1 \\ 1 & 0 & 1 & 1 & 1 & 0 & 0 & 1 \end{bmatrix}}} & (23) \end{matrix}$

where: u_(i), u_(j)′εR

This operation is expressed merely as the product of a matrix and is the same as Eq. (10). In an environment where a permutation operation using masked data or a permutation operation using a bit shift or cyclic shift is possible by processing every 32 bits, the required number of processing steps is small, and hence fast processing can be achieved. However, since such operation processing cannot be performed in a hardware environment formed by an 8-bit accumulator type CPU, a small number of registers and a small amount of memory capacity as in the case of a low-end smart card, the operation of Eq. (10) needs to be executed successively, and hence high-speed processing is difficult to perform.

The following description will be given on the assumption that in an implementation environment formed by one 8-bit accumulator, a small number of registers and a small amount of memory, the input data (u₁, u₂, . . . , u₈) is stored in the memory and is read out therefrom, and the permutation output data u₁′, u₂′, . . . , u₈′ is calculated and stored in the memory; the computational complexity in this instance is evaluated. The evaluation is made in terms of the number of times an addition/subtraction is performed, the number of times the memory is written and the number of times the memory is read. And let it be assumed that the permutation operation is performed by calculating Eq. (23) using the above-mentioned matrix P.

Conventional scheme 1: If the permutation operation of Eq. (23) is carried out as defined, then Eq. (10) needs to be calculated successively. The computational complexity in this case is as follows:

Number of additions/subtractions: 36

Number of memory reads: 44

Number of memory writes: 8

With this scheme, the number of memory reads is equal to the total number of elements of the matrix P which have a “1” component. Accordingly, the computational complexity increases with an increase in the number of elements whose components are “1s”.

Conventional scheme 2: In Literature E2 there is described, as the permutation scheme using the matrix P, a scheme that uses GF(2⁸) as the ring R and calculates the following equations.

a₅ = u₅ +u₁ b₁ = u₁ + a₇ u₅′ = a₅ + b₄ u₁′ = b₁ + u₅′ a₆ = u₆ +u₂ b₂ = u₂ + a₈ u₆′ = a₆ + b₁ u₂′ = b₂ + u₆′ a₇ = u₇ +u₃ b₃ = u₃ + a₅ u₇′ = a₇ + b₂ u₃′ = b₃ + u₇′ a₈ = u₈ +u₄ b₄ = u₄ + a₆ u₈′ = a₈ + b₃ u₄′ = b₄ + u₈′

The computational complexity of this scheme is as follows:

Number of additions/subtractions: 16

Number of memory reads: 32

Number of memory writes: 16

This scheme is more effective than scheme 1 in the case where the number of registers used is large and addition instructions are orthogonal (the addition instructions can be executed for all the registers). However, this scheme has such disadvantages such listed below.

(a) Since the scheme essential utilizes that the characteristic of R is 2, it cannot be used when the characteristic is not 2.

(b) Since a large number of registers cannot be used, this scheme is not always efficient in some implementation environments.

(c) The computational complexity depends largely on the component configuration of the matrix P.

Conventional scheme 3: When the number of “1” components is large as in the case of the matrix P, the following calculation scheme can be used.

σ=u ₁ +u ₂ +u ₃ +u ₄ +u ₅ +u ₆ +u ₇ +u ₈

u ₁ ′=σ−u ₁ −u ₈

u ₂ ′=σ−u ₂ −u ₅

u ₃ ′=σ−u ₃ −u ₆

u ₄ ′=σ−u ₄ −u ₇

u ₅ ′=σ−u ₃ −u ₇ −u ₈

u ₆ ′=σ−u ₄ −u ₅ −u ₈

u ₇ ′=σ−u ₁ −u ₅ −u ₆

u ₈ ′=σ−u ₂ −u ₆ −u ₇

The computational complexity of this scheme is as follows:

Number of additions/subtractions: 27

Number of memory reads: 36

Number of memory writes: 9

This scheme is more efficient than scheme 1 when the number of elements of the matrix P having the “1” component accounts for more than 60% of the total number of elements.

In any of the above conventional schemes, the efficiency of the permutation by the matrix P depends on how {0, 1} components of the matrix P are distributed; in particular, the computational complexity is determined by the rate at which the elements of the “1” component are present. That is, there is a possibility that scheme 1 or 3 becomes efficient according to the configuration of the matrix P; hence, these schemes are not versatile. Which of these schemes becomes more efficient depends on whether the number of elements of the matrix P having the “1” component is more than 60% of the total number of elements.

To implement secure permutation that can be used in cryptography, it is desirable that the rates of “0” and “1” components in the matrix P be well balanced. For example, in the case of the above matrix P used for the permutation in the cipher E2, the elements of the “1 ” component is about ⅔ of the total number of matrix elements. Since this value is close to the point of determining which scheme becomes more efficient, schemes 1 to 3 are almost common in the number of times the memory is read. This means that these conventional schemes produce substantially no effects of increasing the processing speed, because reading from or writing to the memory is several times lower in speed than addition and subtraction; therefore, the implementation of any of the schemes will not answer the intended purpose of faster permutation operation.

SUMMARY OF THE INVENTION

It is an object of the present invention to provide a data permutation method and apparatus which permit fast processing for the permutation of data with the BP function in the cipher E2 and the division of data to left and right pieces in the Feistel network through the use of one-word registers.

Another object of the present invention is to provide an inverse calculating method and apparatus which permit reduction of the number of masking operations involved.

Another object of the present invention is to provide a substitution-permutation method and apparatus which permit reduction of the number of memory reference and the required storage capacity.

Still another object of the present invention is to provide an operation method which permits reduction of computational complexity in the permutation using the matrix P.

According to a first aspect of the present invention, there is provided a data permutation method by which, letting one byte be k-bit, k being an integer equal to or greater than 1, input data of 16 bytes set, in units of four bytes, in 4k-bit long first to fourth registers is permutated, the method comprising the steps of:

(a) ANDing 4-byte first mask data with the data of said first register and 4-byte second mask data with the data of said third register, and ORing the two ANDs as first output data;

(b) ANDing 4-byte third mask data with the data of said second register and 4-byte fourth mask data with the data of said fourth register, and ORing the two ANDs as second output data;

(c) ANDing said second mask data with the data of said first register and said first mask data with the data of said third register, and ORing the two ANDs as third output data;

(d) ANDing said fourth mask data with the data of said second register and said third mask data with the data of said fourth register, and ORing the two ANDs as fourth output data; and

(e) outputting said first to fourth data as permutated data;

wherein all bits of predetermined two of four bytes of said first mask data are “1s,” all bits of the remaining two bytes are “0s,” said second mask data is complementary to said first mask data, said third mask data is a 1-byte-rotated version of said first mask data, and said fourth mask data is complementary to said third mask data.

Alternatively, according to a first aspect of the present invention, there is provided a data permutation method by which, letting one byte be k-bit, k being an integer equal to or greater than 1, input data of 16 bytes set, in units of four bytes, in 4k-bit long first to fourth registers is permutated, the method comprising the steps of:

(a) rotating the data of said first and third registers one byte in one direction, and concatenating them to form first concatenated data;

(b) concatenating the data of said second and fourth registers to form second concatenated data;

(c) shifting said first and second concatenated data two bytes in one direction, and extracting, as first and second output data, two pieces of 4-byte data from said shifted first and second concatenated data at one end thereof in the shift direction;

(d) concatenating said rotated data of said third and first registers to form third concatenated data;

(e) concatenating the data of said fourth and second registers to form fourth concatenated data;

(f) shifting said third and fourth concatenated data two bytes in one direction, and extracting, as third and fourth output data, two pieces of 4-byte data from said shifted third and fourth concatenated data at one end thereof in the shift direction; and

(g) outputting said first to fourth output data as permutated data.

According to a second aspect of the present invention, there is provided an inverse calculating apparatus comprising:

input means for storing an input x in storage means;

storage means for storing integers n and i (where n is equal to or greater than 1) and 2^(n)-bit integers x, y, a and b;

first b-initialization means for calculating [x/2] by using said x stored in said storage means (where [x] is the maximum integer not exceeding said x), and for storing the calculation result as b in said storage means;

a-initialization means for storing, as said a, in said storage means the least significant bit of said b stored in said storage means;

second b-initialization means for calculating [(ax+b)/2] by using said a, x and b stored in said storage means and for updating said b stored in said storage means with the calculation result;

y-updating means for calculating y+a×2{circumflex over ( )}(2^(i)) using said a, y and i stored in said storage means and updating said y stored in said storage means with the calculation result (where p{circumflex over ( )}q represents the q-th power of p);

i-updating means for updating said i stored in said storage means to i+1;

a-updating means for calculating −by by using said b and y stored in, said storage means and for updating said a stored in said storage means with the calculation result;

b-updating means for calculating [(b+ax)/(2{circumflex over ( )}(2^(i)))] by using a, b, x and i stored in said storage means and for updating said b stored in said storage means;

y-updating means for calculating y+a×2{circumflex over ( )}(2^(i)) by using said a, y and i stored in said storage means and for updating said y stored in said storage means with the calculation result;

i-updating means for updating said i stored in said storage means to i+1;

control means for reading out said i and n stored in said storage means and actuating said a-updating means, said b-updating means, said y-updating means and said i-updating means one after another until i=n; and

output means for outputting said y stored in said storage means.

According to a third aspect of the present invention, there is provided a substitution-permutation apparatus which, by the following substitution-permutation over a ring R $\begin{bmatrix} y_{1} \\ y_{2} \\ \vdots \\ y_{m} \end{bmatrix} = {{{P\quad\begin{bmatrix} {s_{1}\left( x_{1} \right)} \\ {s_{2}\left( x_{2} \right)} \\ \vdots \\ {s_{n}\left( x_{n} \right)} \end{bmatrix}}\quad {where}\quad P} = \begin{bmatrix} p_{11} & p_{12} & \cdots & p_{1n} \\ p_{21} & p_{22} & \quad & p_{2n} \\ \vdots & \quad & \quad & \vdots \\ p_{m1} & p_{m2} & \cdots & p_{mn} \end{bmatrix}}$ p_(ij) ∈ R,  s_(j):  RR  i = 1, 2, ⋯  , m  j = 1, 2, ⋯  , n

performs a substitution-permutation operation of an input data sequence (x_(j)) to calculate a data sequence (y_(i)), said apparatus comprising:

storage means for storing: precalculated values of v_(i) (whose dimensions are up to m and may differ individually) over said ring R necessary for said substitution-permutation, obtained by swapping rows or columns of said matrix P for some p_(ij) or s_(j) of the same values; a precalculated value of a function S_(k):R→R^(m); precalculated values of n vectors w_(k)εR^(m); and an integer k;

input means for storing said input data sequence x_(j) in said storage means;

k-initialization means for setting said integer k to 0;

k-updating means for updating said k in said storage means to k+1;

S_(k) calculating means for reading out each S_(k) and input data (x_(k)) from said storage means to obtain the result of calculation of a vector S_(k) (x_(k)) and for storing said vector as a vector w_(k) in said storage means;

u_(k)-generating means for reading out of said storage means a set of vectors {v₁} necessary for forming a k-th column of said matrix P and for generating a vector u_(k);

u_(k)*S_(k) calculating means for reading out said w_(k) from said storage means and calculating the product for each element and for updating said w_(k)with the calculation result;

control means for reading out said k stored in said storage means and for actuating said S_(k) calculating means, said u_(k)*S_(k) calculating means and said k-updating means one after another until k=n; and

output means for reading out each w_(k) stored in said storage means and for calculating and outputting their sum.

Alternatively, according to a third aspect of the present invention, a substitution-permutation apparatus which, by the following substitution-permutation over a ring R $\begin{bmatrix} y_{1} \\ y_{2} \\ \vdots \\ y_{m} \end{bmatrix} = {{{P\quad\begin{bmatrix} {s_{1}\left( x_{1} \right)} \\ {s_{2}\left( x_{2} \right)} \\ \vdots \\ {s_{n}\left( x_{n} \right)} \end{bmatrix}}\quad {where}\quad P} = \begin{bmatrix} p_{11} & p_{12} & \cdots & p_{1n} \\ p_{21} & p_{22} & \quad & p_{2n} \\ \vdots & \quad & \quad & \vdots \\ p_{m1} & p_{m2} & \cdots & p_{mn} \end{bmatrix}}$ p_(ij) ∈ R,  s_(j):  RR  i = 1, 2, ⋯  , m  j = 1, 2, ⋯  , n

performs a substitution-permutation operation of an input data sequence (x_(j)) to produce a data sequence (y_(i)), comprisies:

storage means for storing a precalculated value of the following equation with rows of a matrix P rearranged ${{S\quad {P_{1j}\left( x_{j} \right)}} = \begin{bmatrix} {p_{{t{({q1})}}j}{s_{j}\left( x_{j} \right)}} \\ {p_{{t{({{q1} + 1})}}j}{s_{j}\left( x_{j} \right)}} \\ \vdots \\ {p_{{t{({r1})}}j}{s_{j}\left( x_{j} \right)}} \end{bmatrix}}\quad$

 (where b(j) is a natural number equal to or greater than 1 but equal to or smaller than m, l=1, 2, . . . , b(j), t:{1, 2, . . . , m}→{1, 2, . . . , m} is permutation, and ql and rl are natural numbers equal to or greater than 1 but equal to or smaller than n, ql≦rl) together with precalculated values of n vectors w_(k)εR^(m) and an integer k;

input means for storing said input data sequence (x_(i)) in said storage means;

k-initialization means for setting said integer k to 0;

k-updating means for updating said k stored in said storage means to. k+1;

SP_(k) calculating means for reading out input data x_(k) and SP_(lj)(x_(k)) from said storage means, for calculating said SP_(lj)(x_(k)) for each l (where l=1, 2, . . . , b(j)) and concatenating the calculated results in correspondence to a k-th column of said rearranged matrix P to obtain an m-dimensional vector, and: for updating said w_(k) stored in said storage means with said m-dimensional vector as w_(k);

control means for reading out said k stored in said storage means and for actuating said SP_(k) calculating means and said k-updating means one after the other until k=n; and

output means for reading out each w_(k) stored in said storage means and for calculating and outputting their sum.

According to a fourth aspect of the present invention, there is provided a permutation method in which an operating apparatus including an accumulator type CPU and registers is used to permute input data u₁, u₂, . . . , u_(n) by the following equation using an m by n matrix P of predetermined {0, 1} elements to obtain permuted data (u₁′, u₂′, . . . , u_(m)′) $\begin{bmatrix} u_{1}^{\prime} \\ u_{2}^{\prime} \\ \vdots \\ u_{n}^{\prime} \end{bmatrix} = {P\quad\begin{bmatrix} u_{1} \\ u_{2} \\ \vdots \\ u_{n} \end{bmatrix}}$

said method comprising the steps of:

(a) setting each piece of said permuted data u_(j)′ by the following equation using already calculated u_(i)′

 u _(j) ′=u _(i) ′+D _(i)

where j≠i, and j are integers equal to or greater than 1 and equal to or smaller than n, n is an integer equal to or greater than 2 and D_(i) is given by the difference D_(i)=u_(j)′-u_(i)′ between said permuted data u_(j)′ and u_(i)′ defined by said matrix P using said input data u₁, u₂, . . . , u_(n); and

(b) calculating said u_(j)′ for all of said j.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram illustrating the configuration of an E2 cryptographic device that is an example of application of the present invention;

FIG. 2 is a block diagram depicting the configuration of a round function part 22 of each round processing stage in FIG. 1;

FIG. 3 is a diagram depicting the relationship between data arrangements before and after permutation by a byte permutation part 13 in FIG. 1;

FIG. 4 is a diagram for explaining the procedure by which the permutation of FIG. 3 is performed by a logical operation using mask data;

FIG. 5 is a diagram depicting the register contents in the case of performing an inverse calculation by a conventional method in a division part 32 in FIG. 1;

FIG. 6 is a diagram showing an example of the byte permutation by the present invention;

FIG. 7 is a diagram showing another example of the byte permutation by the present invention;

FIG. 8 is a diagram depicting the procedure which is followed in performing the byte permutation of FIG. 6 by a logical operation using mask data;

FIG. 9 is a diagram depicting the procedure which is followed in performing the byte permutation of FIG. 7 by a bit shift and a cyclic shift;

FIG. 10 is a block diagram depicting the configuration of a byte permutation part 13;

FIG. 11 is a flowchart showing the procedure of an inverse calculation by the present invention;

FIG. 12 is a block diagram depicting an example of the configuration of an apparatus for the inverse calculation of FIG. 11;

FIG. 13 is a block diagram depicting an example of the configuration of an apparatus for performing the substitution-permutation by this invention method in an S and P function parts in the round function part 22 of FIG. 2;

FIG. 14 is a block diagram depicting another example of the configuration of the apparatus for performing the substitution-permutation by this invention method in an S and P function parts in the round function part 22 of FIG. 2; and

FIG. 15 is a block diagram illustrating an example of the configuration of an apparatus for performing the operation of a P function part 22P in FIG. 2.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS Embodiment 1

A description will be given first of the procedure by the present invention which facilitates the operation in the byte permutation part, that is, the BP function part 13 in FIG. 1 in the cipher E2. In the following description, 16 pieces of input k-bit byte data will be identified as a₀, a₁, . . . a₁₅, and permutated output data as A₁,A₂,A₃,A₄. The BP function part 13 is supplied with 16 pieces of 1-byte input data a₀, a₁, . . . , a₁₅ and outputs byte-permutated data as right and left data. In this embodiment the arrangement of output data is appropriately chosen and the permutation for rearranging the data as chosen is performed by a procedure involving a smaller number of steps than in the prior art.

In this embodiment, the four pieces of data {a_(4i+j)} (where 0≦j≦3) are stored as a_(4i+0), a_(4i+1), a_(4i+2), a_(4i+3) in each 4k-bit register T_(i) (where i=0, 1, 2, 3) shown in FIG. 8; the four pieces of data are included in 16 pieces of k-bit data {a_(4i+j)} (where 0≦i≦3, 0≦j≦3) which are input into the BP function part 13 (FIG. 1). The data stored in this form will hereinafter be described as follows:

T _(i) =[a _(4i+0) a _(4i+1) a _(4i+2) a _(4i+3)]  (24)

The left data set [L] and the right data set [R] at the output of the BP function part 13 are defined in the cipher E2 as follows:

$\begin{matrix} \begin{matrix} {\lbrack L\rbrack = \left\{ {\left. a_{{4{({i + {j\quad {mod}\quad 4}})}} + j} \middle| {0 \leq i \leq 1} \right.,{0 \leq j \leq 3}} \right\}} \\ {= \left\{ {a_{0},a_{3},a_{4},a_{5},a_{9},a_{10},a_{14},a_{15}} \right\}} \end{matrix} & \text{(25A)} \\ \begin{matrix} {\lbrack R\rbrack = \left\{ {\left. a_{{4{({i + {j\quad {mod}\quad 4}})}} + j} \middle| {2 \leq i \leq 3} \right.,{0 \leq j \leq 3}} \right\}} \\ {= \left\{ {a_{1},a_{2},a_{6},a_{7},a_{8},a_{11},a_{12},a_{13}} \right\}} \end{matrix} & \text{(25B)} \end{matrix}$

This embodiment also performs the permutation and division of data accordingly. Incidentally, in the specification of the cipher E2, it does not matter even if the right and left data sets differ in the order of 8-byte data; hence, in the present invention, the order of data in either of the right and left data sets is chosen as to achieve the intended reduction of the computationaal complexity in the permutation using masking operations and in the permutation using shift operations.

The input 16-byte data a₀,a₁ . . . , a₁₅ is rearranged not on such a byte-by-byte basis as depicted in FIG. 3 but, for example, every two bytes as depicted in FIG. 6 or 7. This permits reduction of procedure steps as described below.

In this embodiment, 1 byte is k-bit and k can be implemented by an arbitrary integer; but k is set at 8 for the sake of brevity. In the following description, let it be assumed that pieces of data “O” and “I” represent binary numbers “00000000” and “11111111,” respectively. They will also be denoted by “00” and “ff” in the hexadecimal notation.

FIG. 8 depicts the procedure by which the byte permutation shown in FIG. 6 is performed using mask data. The registers T₀, T₁, . . . , T₃ are 4k-bit; long registers, which are used to permute and divide 16 pieces of k-bit data {a_(4i+j)} (0≦i≦3, 0≦j≦3) into a set {a_(4(i+j mod 4)+j)} (0≦i≦1, 0≦j≦3) and a set {a_(4(i+j mod 4)+j)} (2≦i≦3, 0≦j≦3) as described below.

Step 1: Data {a_(4i+j)} (i=0,1,2,3; j=0,1,2,3) is stored in each register T_(i). Data (O, a₁, a₂, O) obtained by ANDing the value (a₀,a₁,a₂,a₃) of the register T₀ and mask data MD₀=(2^(3k)−2^(k))=(O, I, I, O) of a mask register MRG0 is stored in a register T₀′; data (a₈, O, O, a₁₁) obtained by ANDing the value (a₈,a₉,a₁₀,a₁₁) of the register T₂ and mask data MD₂=(2^(4k)−2^(3k)+2^(k)−1)=(I, O, O, I) of a mask register MRG2 is stored in a register T₂′; and the value (a₈,a₁,a₂,a₁₁) obtained by ORing the values of the registers T₀′ and T₂′ is stored in a register T₄.

Step 2: Data (O, O, a₆, a₇) obtained by ANDing the value (a₄,a₅,a₆,a₇) of the register T₁ and mask data MD₁=(2^(2k)−1)=(O, O, I, I) of a mask register MRG1 is stored in a register T₁′; data (a₁₂, a₁₃, O, O) obtained by ANDing the value (a₁₂,a₁₃,a₁₄,a₁₅) of the register T₃ and mask data MD₃=(2^(4k)−2^(2k))=(I, I, O, O) of a mask register MRG3 is stored in a register T₃′; and the value (a₁₂,a₁₃,a₆,a₇) obtained by ORing the values of the registers T₁′ and T₃′ is stored in a register T₅.

Step 3: Data (a₀, O, O, a₃) obtained by ANDing the value (a₀,a₁,a₂,a₃) of the register T₀ and mask data (2^(4k)−2^(3k)+2^(k)−1)=(I, O, O, I) of a mask register MRG0′ is stored in a register T₀″; data (O, a₉, a₁₀, O) obtained by ANDing the value (a₈,a₉a₁₀,a₁₁) of the register T₂ and mask data (2^(3k)−2^(k))=(O, I, I, O) of a mask register MRG2′ is stored in a register T₂″; and the OR (a₀,a₉,a₁₀,a₃) of the values of the registers T₀″ and T₂″ is stored in a register T₆.

Step 4: Data (a₄, a₅, O, O) obtained by ANDing the value (a₄,a₅,a₆,a₇) of the register T₁ and mask data (2^(4k)−2^(2k))=(I, I, O, O) of a mask register MRG1′ is stored in a register T₁″; data (O, O, a₁₄, a₁₅) obtained by ANDing the value (a₁₂,a₁₃,a₁₄,a₁₅) of the register T₄ and mask data (2^(2k)−1)=(O, O, I, I) of a mask register MRG3′ is stored in a register T₃″; and the OR (a₄,a₅,a₁₄,a₁₅) of the values of the registers T₁″ and T₃″ is stored in a register T₇.

Step 5: The pieces of data of the two register groups T₆-T₇ and T₄-T₅ are output as left and right pieces of data.

The permutation processing using mask data as described above can be expressed by the following logical operation, in which the data is represented in hexadecimal.

A ₁=(z ₁ff0000ff)(z ₃00ffff00)

A ₂=(z ₂ffff0000)(z ₄0000ffff)

A ₃=(z ₃ff0000ff)(z ₁00ffff00)

A ₄=(z ₄ffff000)(z ₂0000ffff)  (26)

As is evident from the above equation, the numbers of AND and OR operations using mask data involved in obtaining the permuted outputs A₁,A₂,A₃,A₄ are eight and four, which are smaller than in the prior art example described previously with reference to Eq. (16).

FIG. 9 depicts the procedure for the permutation shown in FIG. 7. In the FIG. 7 example, too, each piece of 4-byte data is rearranged in units of two bytes. This permutation is carried out as depicted in FIG. 9 using, for instance, shift and cyclic shift (i.e., rotation) techniques.

Each register T_(i) is 4k-bit long and k=8 in this example, too. This is a data permutation-division method which permute and divide 16 pieces of k-bit data {a_(4i+j)} (0≦i≦3, 0≦j≦3) into a set {a_(4(i+j mod 4)+j)} (0≦i≦1, 0≦j≦3) and a set {a_(4(i+j mod 4)+j)} (2≦i≦3, 0≦j≦3).

Step 1: The data {a_(4i+j)} (0≦i≦3, 0≦j≦3) is stored in each register T_(i)(i=0, 1,2,3).

Step 2: The values of (a₀,a₁,a₂,a₃) and (a₈,a₉,a₁₀,a₁₁) of the registers T₀ and T₂ are rotated k-bit in one direction, in this example, to right.

Step 3: The registers T₀ and T₂ are concatenated into an apparently 8k-bit long register T₀′; its data is shifted left 2k bits and then 4k-bit data (a₁,a₂,a₁₁,a₈) extracted from the register at the end in the shift direction is stored in the register T₄. The registers T₁ and T₃ are concatenated into an apparently 8k-bit long register T₂′; its data is shifted left 2k bits and then 4k-bit data (a₆,a₇,a₁₂,a₁₃) extracted from the register at the end in the shift direction is stored in the register T₅.

Step 4: The registers T₂ and T₀ are concatenated into an apparently 8k-bit long register T₀″; its data is shifted right 2k bits and then 4k-bit data (a₉,a₁₀,a₃,a₀) extracted from the register at the end in the shift direction is stored in the register T₆. The registers T₃ and T₁ are concatenated into an apparently 8k-bit long register T₂″; its data is shifted right 2k bits and then 4k-bit data (a₁₄,a₁₅,a₄,a₅) extracted from the register at the end in the shift direction is stored in the register T₇.

Step 5: The pieces of data A₁, A₂ and A₃, A₄ of the two register groups T₆-T₇ and T₄-T₅ are output as left and right pieces of data.

In the example of FIG. 9, the same results are obtained irrespective of the shift direction in steps 3 and 4. When the direction of rotation is reversed in step 2, the resulting pieces of data are the same as in the case where the contents of the registers T₄ and T₆ are exchanged, thus achieving similar permutation-division.

The processing depicted in FIG. 9 can be expressed by the following operation, in which the following definitions are used.

x<<b: b-bit left shift of x

x>>b: b-bit right shift of x

ROL(x,y)=(x<<b)(x>>(w−k)), where w is the number of bits of x.

ROR(x,b)=(x>>b)(x>>(w−b)), where w is the number of bits of x.

SHLD(x,y,b)=(x<<b)(y>>(w−b)), where w is the number of bits of y.

SHRD(x,y,b)=(x>>b)(y<<(w−b)), where w is the number of bits of y.

A ₁ =SHRD(ROR(z ₃ ,k),ROR(z ₁ ,k),2k)

A ₂ =SHRD(z ₄ ,z ₂,2k)

A ₃ =SHLD(ROR(z ₁ ,k),ROR(z ₃ ,k),2k)

A₄ =SHLD(z ₂ ,z ₄,2k)  (27)

With this method, the permuted results A₁,A₂,A₃,A₄ obtained by two cyclic shifts and four concatenated shifts.

The byte permutation could also be performed by the combined use of the first-mentioned method (utilizing mask data) and the second-mentioned method (utilizing bit shift and cyclic shift). For example, in the first method, the second method may be used to calculate A₂ and A₄ in Eq. (26) by the following equation:

A ₂ =SHRD(z ₄ ,z ₂,2k)

A ₄ =SHLD(z ₂ ,z ₄,2k)  (28)

Also it is possible to use the second method to calculate A₁ and A₃ in Eq.(26) by the following equation:

A ₁ =SHRD(ROR(z ₃ ,k), ROR(z ₁ ,k),2k)

A₃ =SHLD(ROR(z₁ ,k), ROR(z ₃ ,k),2k)  (29)

Conversely, in the method using Eq. (27), the first method may also be used to calculate A₂ and A₄ by the following equation:

A ₂=(z ₄0000ffff)(z ₂ffff0000)=(a ₄ ,a ₅ ,a ₁₄ ,a ₁₅)

A ₄=(z ₂0000ffff)(z ₄ffff000)=(a ₁₂ a ₁₃ , a ₆ ,a ₇)  (30)

It is also possible to use the first method to calculate A₁ and A₃ in Eq. (27) by the following equation:

A ₁=(z ₃00ffff00)(z ₁ff0000ff)=(a ₀ ,a ₉ ,a ₁₀ ,a ₃)

A ₃=(z ₁00ffff00)(z ₃ff0000ff)=(a ₉ ,a ₁ ,a ₂ ,a ₁₁)  (31)

The above byte permutation method is also applicable to the BP⁻¹ function part (FIG. 1) that performs inverse processing. For example, when the permutation shown in FIG. 6 is performed in the BP function part 13, the inverse processing needs only to be carried out by the following equation:

z ₁=(A ₁ff0000ff)(A ₃00ffff00)

z ₂=(A ₂ffff0000)(A ₄0000ffff)

z ₃=(A ₃ff0000ff)(A ₁00ffff00)

z ₄=(A ₄ffff0000)(A ₂0000ffff)  (32)

Similarly, when the permutation of FIG. 7 has been carried out, the inverse processing is done by the following equation:

z ₁ =ROL(SHLD(A ₁,A₃,2k),k)

z ₂ =SHLD(A ₂ ,A ₄,2k)

z ₃ =ROL(SHRD(A ₁ ,A ₃,2k),k)

z₄ =SHRD(A ₂ ,A ₄,2k)  (33)

All of the ORs in the above-described first embodiment may also be replaced with additions or XORs.

FIG. 10 illustrates in block form the BP function part 13 that performs the permutation depicted in FIG. 8 or 9. A control part 131 controls respective processing parts following a byte permutation execution program prestored in a memory 130. In an input data storage part 135 there is held input data {a_(4i+j)} (0≦i≦3, 0≦j≦3), which is set in registers T₀ to T₃ in a register part 134 of an operation processing part 132 under the control of the control part 131. The control part 131 follows the permutation executing program to issue register data shift and rotation instructions to predetermined registers SH and RO, controls the data transfer between each shift register and a logical operation part 133, and issues to the latter operation instructions for ORing, ANDing and other logical operations and an instruction for the use of mask data of the mask register MRG in such logical operations. The permuted data is transferred from registers T₄, T₅, T₆ and T₇ of the register part 134 to an output data storage part 136, from which it is output as right and left data.

As depicted in FIG. 3, according to the specification of the cipher E2, the 4 bytes retained in each register of the input part will each be distributed to one of the four registers of the output part when the input data to the BP function part is stored in units of 4 bytes in the four registers from left to right. In the case of an instruction which is used to perform an operation for one register and store therein the operation result as in ordinary MPUs, only one byte can be processed for one instruction; hence, at least 16 instructions are needed to perform the permutation depicted in FIG. 3. In practice, more than 16 instructions are required to perform masking, ORing and other logical operations.

It is considered that 16 instructions may sometimes be enough when each byte of the registers is used directly as an instruction; in this case, however, some MPUs incur a penalty attributable to their configuration, resulting in the processing time becoming longer than in the case of using 16 instructions as usual. Also it is possible to use a method in which input data once written in a memory is read out therefrom and into the BP function part on a byte-wise basis for the permutation therein. In recent MPUs, however, access to the memory causes a penalty in many cases, and in some cases the penalty occurs owing to the MPU configuration as in the above; in these instances, too, the processing time becomes longer than those needed to execute 16 instructions.

In contrast thereto, according to the present invention, the operation procedure by Eq. (27) enables the byte permutation in the cipher E2 to be performed by two rotate instructions and four instruction for shifting right or left the data of the two concatenated registers and for storing the right or left data concerned in a predetermined register. The instructions for latter half processing are standard with, for example, Intel 80386 MPU or later, and hence they can be implemented without any problems. Accordingly, this invention method permits faster processing of the BP function operation than the existing methods.

In an MPU on which such instructions are not concretely implemented, they can be substituted with two masking instructions and one ORing instruction. That is, while in the above the permuted data A₁ in Eq. (27) has been described to be calculated by the processing in which the registers T₂ and T₀ after the cyclic shift are concatenated into a virtually 8k-bit long register T₀″ and the data of the rightmost 4k-bit data of the register T₀″ after the 2k-bit right shift is stored as the data A₁ of the register T₆, the permuted data A₁ can also be obtained by such processing as indicated by Eq. (31), in which data (O, a₉, a₁₀, O) obtained by ANDing data Z₃ of the register T₂ and mask data (2^(3k)−2^(k))=(00ffff00) is stored in a register T₁″ (not shown), data (a₀, O, O, a₃) obtained by ANDing data z₁ of the register T₀ and mask data (2^(4k)−2^(3k)+2^(k)−1)=(ff0000ff) is stored in a register T₃″ (not shown) and the value (a₀, a₉, a₁₀, a₃) obtained ORing the data of the register T₁″ and the data of the register T₃″ is stored in the register T₆. The operation for the data A₃ in Eq. (31) can also be made in a similar way. The operation does not involve the execution of any cyclic shift instruction, and hence it can be described by a total of 12 instructions, ensuring faster operation of the BP function than does the prior art.

Incidentally, the value A₁ by Eq. (31) and the value A₁ held in the register T₆ in FIG. 9 differ in that they have been rotated one byte relative to each other. In either case, however, the register T₆ holds four pieces of data a₀, a₃, a₉ and a₁₀—this guarantees that the registers T₆ and T₇ hold the value of the set [R] just enough. The same is true of the relationship between the value A₃ by Eq. (31) and the value A₃ held in the register T₄ in FIG. 9.

In the cipher E2, since the basic encryption processing part performs byte-by-byte processing, the arrangement of, for example, the right-hand data need not always conform to the specification. That is, the implementation part of the encryption part needs only to correspond to the rearranged byte sequence.

Further, in this embodiment, the sets of bytes after permutation are divided to right and left in a correct order though different from the specified one. With the recent MPUs, it is possible to achieve particularly fast implementation of the BP function part in the cipher E2 for the data permutation and division used in cryptographic technology even when instructions for concatenating two registers into a virtually single register, shifting its data and storing high- or low-order data in the register are implemented on the MPUs. Such data permutation-division by the BP function in the cipher E2 is implemented using a data permutation-division: program, which is offered as being recorded on a recording medium. This facilitates the distribution of the program.

Embodiment 2

A second embodiment of the present invention is intended to efficiently perform an inverse calculation over an integral residue class ring, for example, in the division part 32 of the final transformation part 30 in FIG. 1. In step 3-2 of the afore-mentioned Zassenhaus algorithm, this embodiment immerses a in y not intact but by addition. This utilizes the property of the Zassenhaus algorithm that correct results could be obtained by reversing the sign even without masking in step 3-1.

That is, this embodiment calculates an inverse element y=x⁻¹mod 2^(m) of the input x. Let a and b be temporary variables, m=2^(n) (n≧1) and m be bit lengths of x, y, a and b. According to this embodiment, x is input and stored in storage means, followed by an initial process which: reads out x; calculates [x/2]; stores the calculated result as b in the storage means; stores the least significant bit as a in the storage means; reads out a, x and b; calculates [(ax+b)/2]; updates b with the calculated result; reads out x; and stores low-order two bits of x as y in the storage means.

Next, b and y area read out for i=1, 2, . . . , n−1; −by is calculated; a in the storage means is updated with −by; b, a and x are read out of the storage means and are used to calculate [(b+ax)/(2{circumflex over ( )}(2^(i)))]; b in the storage means is updated with the calculated value; y and a are read out of the storage means; and are used to calculate y+a×2{circumflex over ( )}(2^(i)); and y in the storage means is updated with the calculated value. Note that p{circumflex over ( )}q denotes the q-th power of p.

Next, y is read out of the storage means and output as the result of the inverse calculation.

FIG. 11 depicts the procedure of the inverse calculation described above.

Let a and b be temporary or auxiliary variables, [x] be a Gauss' symbol (the maximum integer not exceeding x) and m=2^(n)(n≧1). The inverse calculation is performed as described below. In this case, x, y, a and b have a bit length of m.

Step 1: Input x.

Step 2: Perform the following calculations as initial processing.

2-1. b:=[x/2]

2-2. a:=the least significant bit of b (S2 in FIG. 11)

2-3. b:=[(ax+b)/2]

2-4. y:=low-order two bits of x (S3 in FIG. 11)

2-5. i:=1(S4 in FIG. 11)

Step 3: Perform the following calculations for i=1, 2, . . . , n−1

3-1. a:=−by

3-2. b:=[(b+ax)/(2{circumflex over ( )}(2^(i)))]

3-3. y:=y+a×2{circumflex over ( )}(2^(i)) (S5 in FIG. 11)

3-4. i:=i+1(S6 in FIG. 11)

Step 4: Output y.

In Step 2, substeps 2-1, 2-2 and 2-3 are performed in this order. Substeps 2-4 and 2-5 may be performed at arbitrary timing in Step 2.

Step 3 may be performed in the order 3-1→3-2→3-3 or 3-1→3-3→3-2, but on recent computers it is preferable from their data dependency to perform step 3 in the order 3-1→3-2→3-3. When i=n−1, b is not necessary, and hence substep 3-2 need not be carried out.

The loop of the algorithm may be described in a developed from of its interations in advance. (The number of iterations of the loop comes into play only on the order of the logarithm of the bit count of the inverse element to be calculated.) With the loop described in advance, it is possible to make the inverse calculation faster by precalculating i-dependent constants.

On ordinary processors divisions and multiplications by 2^(n) can be made faster by shift operations.

The validity of the above inverse calculation algorithm is described in the Appendix to this specification

FIG. 12 illustrates the functional configuration of the inverse calculating apparatus according to this embodiment.

The input data x is stored by an input part 32C in an x-storage area of a storage device 32B. The stored data x is read out of the storage device 32B by first b-initializing means 32A1 in an operation device 32A, wherein it is used to calculate [x/2], which is stored as b in a b-storage area 32B4 of the storage device 32B.

The stored data b is read out by an a-initializing means 32A2 from the storage device 32B, and the least significant bit of the read-out data b is stored in a-storage area 32B3. By second b-initializing means 32A3 a, x and b are read out of the storage device 32B, then [(ax+b)/2] is calculated, and the calculated value is used as b to update the stored content of a b-storage area 32B4.

By y-initializing means 32A4 the stored data x in the storage device 32B is read out therefrom, and its low-order two bits are stored as y in a y-storage area 32B2 of the storage device 32B. By i-initializing means 32A51 is set as i in an i-storage area 32B5 of the storage device 32B.

By a-updating means 32A6 stored data b and y in the storage device 32B are read out therefrom, and −by is calculated, with which the stored data a in the a-storage area 32B3 is updated. By b-updating means 32A7 the stored data a, b, x and i in the storage device 32B are read out therefrom, and [(b+ax)/2{circumflex over ( )}(2^(i))] is calculated, with which the stored data in the b-storage area 32B4 is updated.

By y-updating means 32A8 the stored data a, y and i in the storage device 32B are read out therefrom, and y+ax2{circumflex over ( )}(2^(i)) is calculated, with which the stored data y in the y-storage area 32B2 is updated. By i-updating means 32A9 the stored data i in the storage device 32B is read out therefrom, and i+1 is calculated, with which the stored data i in the i-storage area 32B5 is updated.

By control means 32A10 the stored data i and n are read out of the i-storage area 32B5 and an n-storage area 32B6 of the storage device 32B, then the a-updating means 32A6, the b-updating means 32A7, the y-updating means 32A8 and the i-updating means 32A9 are sequentially actuated until, i=n, and when i becomes equal to n, the stored data y in the storage device 32B is read out therefrom by an output part 32D and output therethrough.

The apparatus of the present invention is capable of performing its respective functions by a computer under program control.

As will be seen from substeps 3-1, 3-2 and 3-3 of Step 3, this embodiment does not involve the bit padding operation, and hence it reduces the workload of bit processing that has been an obstacle to the software implementation of the Zassenhaus algorithm. Thus this embodiment permits faster inverse calculation in mod 2^(m).

The “Zassenhaus method” and the inverse calculating method of the present invention were implemented on a general purpose workstation by C language and compared in terms of processing speed for n=5 (i.e. 32 bits). The input x was determined generating a random number and the operation was repeated for all x's; the two methods were compared, with OS overhead removed. The comparison showed that the inverse calculating method of the present invention was more than 10% faster than the “Zassenhaus method.”

While Embodiment 2 has been described as being applied to the inverse calculation in the division part 32 of the cipher E2 shown in FIG. 1, it is also applicable, for example, to the inverse calculation in mod 2^(m) by the Montgomery algorithm that is used in the modular exponentiation operation over Z/NZ

Embodiment 3

This embodiment is intended to reduce the numbers of memory references and additions involved and the storage capacity required in the substitution-permutation processing by the round function part 22 in the cipher E2 depicted in FIG. 2. In practice, the substitution and permutation of the type indicated by Eq. (17) are not usual and have such properties as listed below in many cases.

(1) Some of pieces of data p_(ij)

or s_(j) are equal.

(2) Even if columns of the input or output are swapped or exchanged, the swap can be accommodated at a different part without decreasing the processing speed, and hence it can be transformed equivalently in terms of algorithm.

(3)The element of R^(n) is stored in a register for storing a word that is the calculation unit on a computer, and can be calculated for each element.

Since the property (3) is implemented on recent processors as typified by an MMX instruction implemented on Intel processors, and since R is widely used which permits the element-by-element calculation of R^(n) by and AND operation feasible on almost all processors, the property is considered to be a practical assumption.

This embodiment reduces the number of memory references and the storage capacity through utilization of the above-mentioned properties.

That is, according to this embodiment, when some of pieces of data p_(ij) or s_(j) are equal to one another in the afore-mentioned equations (17) and (18) expressing the substitution and permutation on the ring R $\begin{matrix} {\begin{bmatrix} y_{1} \\ y_{2} \\ \vdots \\ y_{m} \end{bmatrix} = {P\quad\begin{bmatrix} {s_{1}\left( x_{1} \right)} \\ {s_{2}\left( x_{2} \right)} \\ \vdots \\ {s_{n}\left( x_{n} \right)} \end{bmatrix}}} & (17) \end{matrix}$

where $\begin{matrix} {{P = \begin{bmatrix} p_{11} & p_{12} & \cdots & p_{1n} \\ p_{21} & p_{22} & {\quad \cdots} & p_{2n} \\ \vdots & {\vdots \quad} & {⋰\quad} & \vdots \\ p_{m1} & p_{m2} & \cdots & p_{mn} \end{bmatrix}}{{p_{ij} \in R},\quad {{s_{j}\text{:}\quad {RR}\quad i} = 1},2,\cdots \quad,{{m\quad j} = 1},2,\cdots \quad,n}} & (18) \end{matrix}$

rows of the matrix P expressing the permutation are rearranged, then vector v₁εR^(r) (The dimension r is up to m and the vectors may differ in dimension.) on the ring R and the function S_(k)R→R^(r) (where k=1, 2, . . . n, r≦m), which are necessary for the substitution and permutation, are precalcuated for each x_(i), and the precalculated values are stored in storage means. For the input x_(i): S_(k) is read out of the storage means, and a vector S_(k)(x_(i)) is calculated; a set of vectors {v_(i)} necessary for forming a k-th column of the matrix P is read out of the storage means and a vector u_(k) is generated; then u_(k) S_(k)(x_(i)) (where * is the product for each vector element) is calculated, and these values are added together to obtain a data sequence y_(i).

This embodiment will be described below concretely. In practice, the actual substitution and permutation mostly use a field as the ring R, and hence R will be limited specifically to a unitary ring (including the unit element of multiplication). In the interests of simplicity, this embodiment will be described in connection with the case where the calculation of Eq. (17) is P_(ij) ε{0, 1} and the pieces of data s_(j) are identical. When the data s_(j) have several kinds of pieces and some of them are equal, or when the data p_(ij) have pieces taking other values than 0 and 1 and some of them are equal, the operation is less efficient than the examples described below but more efficient than in the case of the conventional method set forth in Literature S.

Embodiment 3-1

Consider the case of calculating Eq. (17). When all pieces of data s_(j) are the same s, setting $\begin{matrix} {{v_{j} = {{\begin{bmatrix} p_{1j} \\ p_{2j} \\ \vdots \\ p_{mj} \end{bmatrix}\quad j} = 1}},2,\cdots \quad,n} & (32) \\ {{S\text{:}\quad {RR^{m}}};\quad {{S\quad (x)} = \begin{bmatrix} {s(x)} \\ {s(x)} \\ \vdots \\ {s(x)} \end{bmatrix}}} & (33) \end{matrix}$

enables Eq. (20) to be written as follows: $\begin{matrix} {{{S\quad P\text{:}\quad {RR^{m}}};\quad {{S\quad P_{j}\quad (x)} = {\begin{bmatrix} {p_{1j}{s\left( x_{j} \right)}} \\ {p_{2j}{s\left( x_{j} \right)}} \\ \vdots \\ {p_{mj}{s\left( x_{j} \right)}} \end{bmatrix} = {v_{j}*{S\left( x_{j} \right)}}}}},{j = 1},2,\ldots \quad,n} & (34) \end{matrix}$

where * is the product for each element of the vector.

From the above it will be understood that, by precalculating S and prestoring the calculated value in a memory, Eq. (17) can be calculated with n memory references for x_(l) to x_(n), n multiplications to obtain the product * for each vector element and n−1 additions of n column vectors. The prior art stores SP_(l) to SP_(n), but this embodiment stores only S and hence reduces the amount of data stored down to 1/n.

Embodiment 3-2

Consider the case of calculating Eq. (17) in an environment where the calculation unit is smaller than R^([(m+1)/2]) (where [(m+1)/2] is the maximum integer not exceeding (m+1)/2). The following example is applicable to ordinary matrices P. To facilitate a better understanding of the invention, consider the application of the invention to the case of the following matrix (Eq. 35) used in the cipher E2, that is, to the substitution and permutation (Eq. 36). $\begin{matrix} {P = \begin{bmatrix} 0 & 1 & 1 & 1 & 1 & 1 & 1 & 0 \\ 1 & 0 & 1 & 1 & 0 & 1 & 1 & 1 \\ 1 & 1 & 0 & 1 & 1 & 0 & 1 & 1 \\ 1 & 1 & 1 & 0 & 1 & 1 & 0 & 1 \\ 1 & 1 & 0 & 1 & 1 & 1 & 0 & 0 \\ 1 & 1 & 1 & 0 & 0 & 1 & 1 & 0 \\ 0 & 1 & 1 & 1 & 0 & 0 & 1 & 1 \\ 1 & 0 & 1 & 1 & 1 & 0 & 0 & 1 \end{bmatrix}} & (35) \\ {\begin{bmatrix} y_{0} \\ y_{1} \\ y_{2} \\ y_{3} \\ y_{4} \\ y_{5} \\ y_{6} \\ y_{7} \end{bmatrix} = {\begin{bmatrix} 0 & 1 & 1 & 1 & 1 & 1 & 1 & 0 \\ 1 & 0 & 1 & 1 & 0 & 1 & 1 & 1 \\ 1 & 1 & 0 & 1 & 1 & 0 & 1 & 1 \\ 1 & 1 & 1 & 0 & 1 & 1 & 0 & 1 \\ 1 & 1 & 0 & 1 & 1 & 1 & 0 & 0 \\ 1 & 1 & 1 & 0 & 0 & 1 & 1 & 0 \\ 0 & 1 & 1 & 1 & 0 & 0 & 1 & 1 \\ 1 & 0 & 1 & 1 & 1 & 0 & 0 & 1 \end{bmatrix}\quad\begin{bmatrix} {s\left( x_{0} \right)} \\ {s\left( x_{1} \right)} \\ {s\left( x_{2} \right)} \\ {s\left( x_{3} \right)} \\ {s\left( x_{4} \right)} \\ {s\left( x_{5} \right)} \\ {s\left( x_{6} \right)} \\ {s\left( x_{7} \right)} \end{bmatrix}}} & (36) \end{matrix}$

The horizontal line in the matrix of Eq. (36) is intended only to make it easy to see. It should be noted that a substitution with no permutation is also needed at end of the operation in the cipher E2.

To implement the substitution and permutation using the matrix P by the method proposed in Literature S, 4-element column vectors forming the upper half submatrix of P are four kinds vectors each containing a 0, the left-hand four column vectors forming the lower half matrix are also four kinds of vectors each containing a 0, and the right-hand column vectors of the lower: half matrix are four kinds of vectors each containing two 0s. Accordingly, to perform $\begin{bmatrix} 0 \\ {s(x)} \\ {s(x)} \\ {s(x)} \end{bmatrix},\begin{bmatrix} {s(x)} \\ 0 \\ {s(x)} \\ {s(x)} \end{bmatrix},\begin{bmatrix} {s(x)} \\ {s(x)} \\ 0 \\ {s(x)} \end{bmatrix},\begin{bmatrix} {s(x)} \\ {s(x)} \\ {s(x)} \\ 0 \end{bmatrix},\begin{bmatrix} 0 \\ 0 \\ {s(x)} \\ {s(x)} \end{bmatrix},\begin{bmatrix} {s(x)} \\ 0 \\ 0 \\ {s(x)} \end{bmatrix},\begin{bmatrix} {s(x)} \\ {s(x)} \\ 0 \\ 0 \end{bmatrix},\begin{bmatrix} 0 \\ {s(x)} \\ {s(x)} \\ 0 \end{bmatrix}$

and only permutation, the following tables are required. $\begin{bmatrix} {s(x)} \\ 0 \\ 0 \\ 0 \end{bmatrix},\begin{bmatrix} 0 \\ {s(x)} \\ 0 \\ 0 \end{bmatrix},\begin{bmatrix} 0 \\ 0 \\ {s(x)} \\ 0 \end{bmatrix},\begin{bmatrix} 0 \\ 0 \\ 0 \\ {s(x)} \end{bmatrix}$

In this instance, letting the memory capacity necessary for storing #R (where # represents the number of elements of a set) elements of R⁴ be one unit (which definition will hereinafter be applied), the computation cost is as follows:

Required memory capacity: 12

Number of table references: 16

Number of additions: 14

In this embodiment, the order of calculation of Eq. (36) is changed by swapping columns of the matrix P to: $\begin{matrix} {\begin{bmatrix} y_{0} \\ y_{7} \\ y_{4} \\ y_{3} \\ y_{6} \\ y_{1} \\ y_{2} \\ y_{5} \end{bmatrix} = {\begin{bmatrix} 0 & 1 & 1 & 1 & 1 & 1 & 1 & 0 \\ 1 & 0 & 1 & 1 & 1 & 0 & 0 & 1 \\ 1 & 1 & 0 & 1 & 1 & 1 & 0 & 0 \\ 1 & 1 & 1 & 0 & 1 & 1 & 0 & 1 \\ 0 & 1 & 1 & 1 & 0 & 0 & 1 & 1 \\ 1 & 0 & 1 & 1 & 0 & 1 & 1 & 1 \\ 1 & 1 & 0 & 1 & 1 & 0 & 1 & 1 \\ 1 & 1 & 1 & 0 & 0 & 1 & 1 & 0 \end{bmatrix}\quad\begin{bmatrix} {s\left( x_{0} \right)} \\ {s\left( x_{1} \right)} \\ {s\left( x_{2} \right)} \\ {s\left( x_{3} \right)} \\ {s\left( x_{4} \right)} \\ {s\left( x_{5} \right)} \\ {s\left( x_{6} \right)} \\ {s\left( x_{7} \right)} \end{bmatrix}}} & (37) \end{matrix}$

The vertical and horizontal lines in the above matrix are intended to facilitate a better understanding of the description given below, and they have no particular meanings. As a result, the required table is formed by: four kinds of 4-element column vectors each containing a 0; one kind of 4-element column vector containing two 0s; one kind of 4-element column vector containing only 1s; and two kinds of 4-element column vector each containing only one 1. The column vectors containing one 1 are used for substitution as well as for permutation. Hence, only the following tables need to be stored: $\begin{bmatrix} 0 \\ {s(x)} \\ {s(x)} \\ {s(x)} \end{bmatrix},\begin{bmatrix} {s(x)} \\ 0 \\ {s(x)} \\ {s(x)} \end{bmatrix},\begin{bmatrix} {s(x)} \\ {s(x)} \\ 0 \\ {s(x)} \end{bmatrix},\begin{bmatrix} {s(x)} \\ {s(x)} \\ {s(x)} \\ 0 \end{bmatrix},\begin{bmatrix} 0 \\ {s(x)} \\ 0 \\ {s(x)} \end{bmatrix},\begin{bmatrix} {s(x)} \\ {s(x)} \\ {s(x)} \\ {s(x)} \end{bmatrix},\begin{bmatrix} {s(x)} \\ 0 \\ 0 \\ 0 \end{bmatrix},\begin{bmatrix} 0 \\ {s(x)} \\ 0 \\ 0 \end{bmatrix},\begin{bmatrix} 0 \\ 0 \\ {s(x)} \\ 0 \end{bmatrix},\begin{bmatrix} 0 \\ 0 \\ 0 \\ {s(x)} \end{bmatrix}$

And the memory reference and addition for x₀, x₁, x₂ and x₃ can be made common thereto. Accordingly, the computation cost in this case is as follows:

Required memory capacity: 10

Number of table references: 12

Number of additions: 11

As compared with the method described in Literature S, the method of this embodiment permits reduction of all of the memory capacity, the number of table references and the number of additions. It must be noted here that, the arrangement of y_(i) (0≦i≦7) on the left-hand side of Eq. (37) does not impair performance.

Embodiment 3—3

Consider the case of calculating Eq. (17) in an environment where the calculation unit is smaller than R^([(m+1)/2]) as is the case with Embodiment 3-2 and the following shift operation can be performed fast. $\begin{matrix} {{\begin{bmatrix} x_{0} \\ x_{1} \\ x_{2} \\ x_{3} \\ \vdots \\ \vdots \\ x_{n} \end{bmatrix}\quad \quad \begin{bmatrix} 0 \\ 0 \\ x_{0} \\ x_{1} \\ \vdots \\ \vdots \\ x_{n - 2} \end{bmatrix}}\quad \text{~~(Example~~of~~shift~~of  low-order~~two~~elements)}} & (38) \end{matrix}$

As is the case with Embodiment 3-2, this embodiment is also applicable to ordinary matrices P, but for simplicity sake, this example will be described as being applied to the matrix P (see Eq. 35)) and substitution-permutation (see Eq. (36)) used in the cipher E2.

As is the case with Embodiment 3-2, the order of calculation is changed by swapping rows of the matrix P as follows: $\begin{matrix} {\begin{bmatrix} y_{0} \\ y_{1} \\ y_{3} \\ y_{2} \\ y_{6} \\ y_{7} \\ y_{5} \\ y_{4} \end{bmatrix} = {\begin{bmatrix} 0 & 1 & 1 & 1 & 1 & 1 & 1 & 0 \\ 1 & 0 & 1 & 1 & 0 & 1 & 1 & 1 \\ 1 & 1 & 1 & 0 & 1 & 1 & 0 & 1 \\ 1 & 1 & 0 & 1 & 1 & 0 & 1 & 1 \\ 0 & 1 & 1 & 1 & 0 & 0 & 1 & 1 \\ 1 & 0 & 1 & 1 & 1 & 0 & 0 & 1 \\ 1 & 1 & 1 & 0 & 0 & 1 & 1 & 0 \\ 1 & 1 & 0 & 1 & 1 & 1 & 0 & 0 \end{bmatrix}\quad\begin{bmatrix} {s\left( x_{0} \right)} \\ {s\left( x_{1} \right)} \\ {s\left( x_{2} \right)} \\ {s\left( x_{3} \right)} \\ {s\left( x_{4} \right)} \\ {s\left( x_{5} \right)} \\ {s\left( x_{6} \right)} \\ {s\left( x_{7} \right)} \end{bmatrix}}} & (39) \end{matrix}$

In the processing for x₄, x₅, x₆, x₇: as regards y₀, y₁, y₃, y₂, memory-stored reference tables are used intact; and as for y₆, y₇, y₅ and y₄, values read out of the memory-stored reference tables for y₀, y₁, y₃and y₂ are shifted down one element, down two elements, up one element and up two elements, respectively. That is, the leftmost column vector of the upper right submatrix of the matrix P is shifted down one element to obtain the leftmost column vector of the lower right submatrix, then the column vector second from the left-hand side of the upper right submatrix is shifted down two elements to obtain the column vector second from the left-hand side of the lower right submatrix, and thereafter the column vectors third and fourth from the left-hand side of the upper right submatrix are shifted up one element and two elements, respectively, to obtain the column vectors third and fourth from the left-hand side of the lower right submatrix.

Accordingly, all the tables that need to be stored are only such as follows: ${{S\quad {P_{0}(x)}} = \begin{bmatrix} 0 \\ {s(x)} \\ {s(x)} \\ {s(x)} \end{bmatrix}},\quad {{S\quad {P_{1}(x)}} = \begin{bmatrix} {s(x)} \\ 0 \\ {s(x)} \\ {s(x)} \end{bmatrix}},{{S\quad {P_{2}(x)}} = \begin{bmatrix} {s(x)} \\ {s(x)} \\ 0 \\ {s(x)} \end{bmatrix}},\quad {{S\quad {P_{3}(x)}} = {\begin{bmatrix} {s(x)} \\ {s(x)} \\ {s(x)} \\ 0 \end{bmatrix}\begin{bmatrix} {s(x)} \\ 0 \\ 0 \\ 0 \end{bmatrix}}},\begin{bmatrix} 0 \\ {s(x)} \\ 0 \\ 0 \end{bmatrix},\begin{bmatrix} 0 \\ 0 \\ {s(x)} \\ 0 \end{bmatrix},\begin{bmatrix} 0 \\ 0 \\ 0 \\ {s(x)} \end{bmatrix}$

Letting the k-element up-shift operation and the k-element down-shift operation be represented by SU_(k) and SD_(k), respectively, and setting

T←SP ₀(x ₀)+SP ₁(x ₁)+SP ₃(x ₂)+SP ₂(x ₃)

U ₀ ←SP ₁(x ₄)

U ₁ ←SP ₃(x ₅)

U ₂ ←SP ₂(x ₆)

U ₃ ←SP ₀(x ₇)  (40)

the following calculations can be conducted: $\begin{matrix} {{\begin{bmatrix} y_{0} \\ y_{1} \\ y_{3} \\ y_{2} \end{bmatrix}\quad \quad T} + U_{0} + U_{1} + U_{2} + U_{3}} & (41) \\ {{\begin{bmatrix} y_{6} \\ y_{7} \\ y_{5} \\ y_{4} \end{bmatrix}\quad \quad T} + {S\quad {D_{1}\left( U_{0} \right)}} + {S\quad {D_{2}\left( U_{1} \right)}} + {S\quad {U_{1}\left( U_{2} \right)}} + {S\quad {U_{2}\left( U_{3} \right)}}} & (42) \end{matrix}$

Accordingly, this embodiment also reduces the computation cost as compared with the method of Literature S in terms of the memory capacity, the number of memory references and the number of additions as follows:

Required memory capacity: 8

Number of table references: 8

Number of additions: 11

Number of shifts: 4

In this embodiment, too, it should be noted that the arrangement of y_(i) (0≦i≦7) on the left-hand side does not incur performance degradation.

Embodiment 3-4

This embodiment is also applicable to ordinary matrices P in some cases, but for the sake of simplicity, the embodiment will be described in connection with the case where the matrix P (see Eq. (35)) and substitution and permutation (see Eq. (36)) used in the cipher E2 are defined for a ring R of a characteristic 2.

As is the case with Embodiment 3-3, respective rows of the matrix P are swapped to obtain $\begin{matrix} {\begin{bmatrix} y_{0} \\ y_{1} \\ y_{2} \\ y_{3} \\ y_{6} \\ y_{7} \\ y_{4} \\ y_{5} \end{bmatrix} = {\begin{bmatrix} 0 & 1 & 1 & 1 & 1 & 1 & 1 & 0 \\ 1 & 0 & 1 & 1 & 0 & 1 & 1 & 1 \\ 1 & 1 & 0 & 1 & 1 & 0 & 1 & 1 \\ 1 & 1 & 1 & 0 & 1 & 1 & 0 & 1 \\ 0 & 1 & 1 & 1 & 0 & 0 & 1 & 1 \\ 1 & 0 & 1 & 1 & 1 & 0 & 0 & 1 \\ 1 & 1 & 0 & 1 & 1 & 1 & 0 & 0 \\ 1 & 1 & 1 & 0 & 0 & 1 & 1 & 0 \end{bmatrix}\quad\begin{bmatrix} {s\left( x_{0} \right)} \\ {s\left( x_{1} \right)} \\ {s\left( x_{2} \right)} \\ {s\left( x_{3} \right)} \\ {s\left( x_{4} \right)} \\ {s\left( x_{5} \right)} \\ {s\left( x_{6} \right)} \\ {s\left( x_{7} \right)} \end{bmatrix}}} & (43) \end{matrix}$

Note the upper right and lower right submatrices of the above matrix. $\begin{matrix} {{Q_{U} = \begin{bmatrix} 1 & 1 & 1 & 0 \\ 0 & 1 & 1 & 1 \\ 1 & 0 & 1 & 1 \\ 1 & 1 & 0 & 1 \end{bmatrix}},\quad {Q_{D} = \begin{bmatrix} 0 & 0 & 1 & 1 \\ 1 & 0 & 0 & 1 \\ 1 & 1 & 0 & 0 \\ 0 & 1 & 1 & 0 \end{bmatrix}}} & (44) \end{matrix}$

In this instance, the following equation holds: $\begin{matrix} {{Q_{U} - Q_{D}} = {\begin{bmatrix} 1 & 1 & 0 & 1 \\ 1 & 1 & 1 & 0 \\ 0 & 1 & 1 & 1 \\ 1 & 0 & 1 & 1 \end{bmatrix} = {{S\quad {D_{1}\left( Q_{U} \right)}} + {S\quad {U_{3}\left( Q_{U} \right)}}}}} & (45) \end{matrix}$

It must be noted here that a ring of a character 2 is considered as R.

If the following table is prepared in advance as in the case of Embodiment 3—, ${{S\quad {P_{0}(x)}} = \begin{bmatrix} 0 \\ {s(x)} \\ {s(x)} \\ {s(x)} \end{bmatrix}},\quad {{S\quad {P_{1}(x)}} = \begin{bmatrix} {s(x)} \\ 0 \\ {s(x)} \\ {s(x)} \end{bmatrix}},{{S\quad {P_{2}(x)}} = \begin{bmatrix} {s(x)} \\ {s(x)} \\ 0 \\ {s(x)} \end{bmatrix}},\quad {{S\quad {P_{3}(x)}} = \begin{bmatrix} {s(x)} \\ {s(x)} \\ {s(x)} \\ 0 \end{bmatrix}}$

the following calculation can be performed by Eq. (45):

T←SP ₀(x ₀)+SP ₁(x ₁)+SP hd 2 (x ₂)+SP ₃(x ₃)

U←SP ₁(x ₄)+SP ₂(x ₅)+SP hd 3 (x ₆)+SP ₀(x ₇)

$\begin{matrix} \begin{matrix} {{\begin{bmatrix} y_{0} \\ y_{1} \\ y_{2} \\ y_{3} \end{bmatrix}\quad \quad T} + U} \\ {{\begin{bmatrix} y_{6} \\ y_{7} \\ y_{4} \\ y_{5} \end{bmatrix}\quad \quad \begin{bmatrix} y_{0} \\ y_{1} \\ y_{2} \\ y_{3} \end{bmatrix}} - {S\quad {D_{1}(U)}} - {S\quad {D_{3}(U)}}} \end{matrix} & (46) \end{matrix}$

In this case, the computation cost is as follows:

Number of table references (for calculation of SP_(j)): 8

Number of additions/subtractions (for calculation of +): 9

Number of shifts (for calculations of SU and SD): 2

Thus, this embodiment permits further reduction of the number of additions/subtractions and the number of shifts than does embodiment 3—3.

Embodiment 3-5

Some processors allow not only the use of the shift operations SU and SD but also the use of the following downward k-element rotation for n elements:

RD _(k)(x)=SD _(k)(x)+SU_(n-k)(x)

In this instance, by using the downward shift for the calculation of Eq. (46) in Embodiment 3-4, the following equation can be conducted. $\begin{matrix} {{\begin{bmatrix} y_{6} \\ y_{7} \\ y_{4} \\ y_{5} \end{bmatrix}\quad \quad \begin{bmatrix} y_{0} \\ y_{1} \\ y_{2} \\ y_{3} \end{bmatrix}} - {R\quad {D_{1}(U)}}} & (47) \end{matrix}$

The computation cost in this case is as follows:

Number of table references (for calculation of SP_(j)): 8

Number of additions (for ± calculation): 8

Number of rotations (for calculation of RD): 1

This embodiment permits further reduction of the number of additions as compare with that in the case of Embodiment 3-4.

FIG. 13 depicts the functional configuration of Embodiment 3-1. The input data x_(i) is stored by input means 32C in an x_(i)-storage area 32B13 of a storage device 32B; the permuted vector v_(k)εR^(r) is stored in a v_(k)-storage area 32B14; and the substitution function S_(k) is stored in an S_(k)-storage area 32B15. Furthermore, the working vector w_(k) is stored in a w_(k)-storage area 32B16, and the working parameter k is stored in a k-storage area 32B17. By k-initializing means 32A19 in the operation device 32A k is initialized to 0, and by S_(k)-calculating means 32A21 the S_(k)-storage area 32B15 is read out using the input data x_(i), and the calculated value of the vector S_(k)(x_(i)) is stored as w_(k) in the w_(k)-storage area 32B16. From the storage means 32B v_(k) and w_(k) are read out, and their product for each element is calculated by v_(k)*S_(k) calculating means 32A22, and the calculated value is used to update w_(k). By k-updating means 32A23 k in the k-storage area 32B17 is updated by being incremented by 1. The S_(k)-calculating means 32A21, the v_(k)*S_(k) calculating means 32A22 and the k-updating means 32A23 are actuated one after another until k=n; respective w_(k) in the storage means 32B are read out therefrom, then their sum is calculated, and the calculated value is output via output means 32D.

FIG. 14 there is depicted the functional configuration of Embodiment 3-2, in which the parts corresponding to those in FIG. 13 are denoted by the same reference numerals. The v_(k)-storage area 32B14 and the S_(k)-storage area 32B1 in FIG. 13 are substituted with SP_(k)-storage area 32B31, in which SP_(k) is stored. By SP_(k) calculating means 32A32 SP_(k)(x_(i)) is calculated in accordance with the input data x_(i), and the calculated value is stored as the vector w_(k) in the w_(k)-storage area 32B16. Embodiment 3-2is identical in construction with Embodiment 3-1 except the above.

In Embodiment 3—3, the read-out SP_(k)(x_(i)) is shifted by shift means 32A33 in FIG. 14, and the shifted SP_(k)(x_(i)) is stored as the vector wk in the w_(k)-storage area 32B16.

Embodiment 4

With the calculation scheme as defined by Eq. (10), upon each calculation of u_(i)′, the calculated value is discarded and the next u_(i)′ is calculated by newly conducting an addition and a subtraction. However, since the defining equation for calculating each u_(i), contains two or more components common to those of the defining equation for calculating another u_(i)′, that is, since the both defining equations are similar to some extent, it is possible to utilize the previous calculated value by expressing the current value u_(i)′ as u_(i)′=u_(j)′+D_(i) using its difference D_(i) from the previous calculated value u_(j)′. This embodiment is intended to reduce the number of times the memory is read.

Embodiment 4-1

In this embodiment, the value u_(i)′ is expressed by u′_(i+1)=u′_(i)+D_(i) and the permutation operation is performed by the following equation:

u ₁ ′=u ₂ +u ₃ +u ₄ +u ₅ +u ₆ +u ₇

u ₂ ′=u ₁ ′+u ₁ −u ₂ −u ₅ +u ₈

u ₃ ′=u ₂ ′+u ₂ −u ₃ +u ₅ −u ₆

u ₄ ′=u ₃ ′+u ₃ −u ₄ +u ₆ −u ₇

u ₅ ′=u ₄ ′−u ₃ +u ₄ −u ₈

u ₆ ′=u ₅ ′+u ₃ −u ₄ −u ₅ +u ₇

u ₇ ′=u ₆ ′−u ₁ +u ₄ −u ₆ +u ₈

u ₈ ′=u ₇ ′+u ₁ −u ₂ +u ₅ −u ₇  (48)

The computation cost by this method is as follows:

Number of additions/subtractions: 32

Number of memory reads: 33

Number of memory writes: 8

As compared with conventional Scheme 1 described previously, this embodiment permits a 25% reduction of the number of memory writes. Incidentally, it must also noted here that since the value u_(i)′ is held in an accumulator at the time of calculating u′_(i+1), no memory access for write is needed.

While this embodiment has been described as being applied to permutation using the matrix P in the cipher E2 for the sake of simplicity, this embodiment is not limited specifically to the matrix P but it may be applied to every permutation that is expressed by the matrix composed of elements {0, 1}. General properties of such application are described below.

The conventional Scheme 1 calculates each value u_(i)′ (where i=1, 2, . . . , 8) after reading in the required value u_(j) (where j=1, 2, 3, . . . , 8). On this account, the total number of memory reads is equal to the total number of “1” components in the matrix P. This means that the larger the total number of “1” components in the matrix P, the larger the number of memory reads and the lower the processing speed.

On the other hand, according to this embodiment, u′_(i+1) can be calculated after reading in only u_(j) (where j=1, 2, . . . , 8) that is the difference between u′_(i+1) and u′_(i). In general, it is expected that the larger the total number of “1” components in the matrix P, the smaller the difference between u′_(i+1) and u′_(i). This means that an increase in the total number of “1” components in the matrix P decreases the number of memory reads, providing increased processing speed.

Unlike the conventional Scheme 2, this embodiment is free from limitations on the method of implementing the matrix P, and hence it is versatile. Incidentally, it is not obvious whether the method this embodiment is superior to the conventional Scheme 3 when the total number of “1” components in the matrix P is extremely large.

Embodiment 4-2

Embodiment 4-1 has been described to calculate u′_(i) in a sequential order starting first for i=1, but the calculation need not always be conducted in such a sequential order because u′_(i) (where i=1, 2, . . . , 8) are described in parallel in the actual implementation. Then the computational complexity, can be reduced by utilizing u′_(j) that decrease its difference from u_(i)′. For example, the calculation of u₇′ from u₆′ requires reading-in of u₁, u₄, u₆ and u₈, but the calculation of u₄′ after u₆′ requires reading-in of only u₅, u₇ and u₈, and hence it permits reduction of the numbers of memory reads and additions/subtractions by one.

By determining the order of calculation of u′_(i) such that the total number of all differences, i.e. the number of memory reads becomes minimum, it is possible to optimize the calculation. Shown below is one of the optimum orders of calculation in the P function part 22 (FIG. 2) in the cipher E2.

u ₆ ′=u ₁ +u ₂ +u ₃ +u ₆ +u ₇

u ₄ ′=u ₆ ′+u ₅ −u ₇ +u ₈

u ₅ ′=u ₄ ′−u ₃ +u ₄ −u ₈

u ₃ ′=u ₅ ′−u ₆ +u ₇ +u ₈

u ₈ ′=u ₃ ′−u ₂ +u ₃ −u ₇

u ₂ ′=u ₈ ′−u ₅ +u ₆ +u ₇

u ₇ ′=u ₂ ′−u ₁ +u ₂ −u ₆

u ₁ ′=u ₇ ′+u ₅ +u ₆ −u ₈  (49)

The computational complexity for permutation by this method is as follows:

Number of additions/subtractions: 25

Number of memory reads: 26

Number of memory writes: 8

Accordingly, the number of memory reads is about 35% smaller than in the case of Scheme 1 and about 25% smaller than in Scheme 2.

While this embodiment has been described as being applied to permutation using the matrix P in the cipher E2 for the sake of simplicity, this embodiment is not limited specifically to the matrix P, and it is evident that the scheme of this embodiment may be applied to every permutation that is expressed by the matrix composed of elements {0, 1}. General properties of such application are described below.

The scheme of this embodiment is apparently improved from the scheme of Embodiment 4-1, and hence it is faster than the conventional Scheme 1 except an address calculation for the write of u_(i)′. Besides, unlike the conventional Scheme 2, this embodiment is free from limitations on the method of implementing the matrix P, and hence it is versatile.

On the other hand, when the total number of “1” component in the matrix P is large, it is expected to provide an order of calculation that decreases the difference between u_(i)′ and u′_(j) as a whole, and in almost all cases it is implemented with the minimum number of memory reads. For example, in the case of Embodiment 4-2, there is such a method that u_(j)′ can be derived from u_(i)′ by three pieces of u_(k) are read out of memories. In general, the number of memory reads necessary for obtaining u_(i)′ from σ by the conventional Scheme 3 may be considered to be equal to or larger than the minimum number of memory reads in Embodiment 4-2. It can be safely said, therefore, that this embodiment is smaller, in almost all cases, than Scheme 3 in the total number of memory reads necessary for obtaining all u_(i)′ (where i=1, 2,. . . , 8)

FIG. 15 illustrates in block form an apparatus that perform the permutation operation by the scheme of Embodiment 4-1 or 4-2. The pieces of input data u₁, u₂, . . . , u₈ to be permuted are held in an input data memory 221. In a program memory 227 there is stored a program for executing the permutation operation of Eq. (48) or (49). A control device 220 follows the program to control an address generator 226 which generates addresses of pieces of data to be read out of the memory 221 one after another and addresses of an output data memory 222 into which pieces of data obtained by the calculation are written. At the same time, the control device 220 iteratively controls additions/subtractions (or XORing) using an accumulator 224 and registers 225. Each calculated value u_(i)′ is held in a temporary data memory 223 or accumulator 224 until it is used to calculate the next u_(j)′.

While Embodiments 4-1 and 4-2 have been described in connection with the permutation operation using a 8 by 8 matrix as the matrix P, it is apparent that they are equally applicable to a permutation operation in which n and m are set at integers equal to or greater than 2, m by n matrix is generally used as the matrix P and permuted data (u₁′, u₂′, . . . , u_(m)′) is calculated by the following equation. $\begin{bmatrix} u_{1}^{\prime} \\ u_{2}^{\prime} \\ \vdots \\ u_{m}^{\prime} \end{bmatrix} = {P\begin{bmatrix} u_{1} \\ u_{2} \\ \vdots \\ u_{n} \end{bmatrix}}$

As described above, it is considered that this embodiment is the smallest in the total number of memory reads; in general, the memory read/write is slower than the addition/subtraction, and this embodiment is faster than any conventional schemes by the amount of address calculation included.

Effect of the Invention

As described above, the byte permutation according to the present invention permits reduction of the number of processing steps by simultaneously performing masking operations of 2 bytes. Alternatively, the processing steps can be decreased by the combined use of rotation and shifts.

In the inverse calculation in mod2^(m), the workload can be reduced by performing additive padding instead of using the bit padding in the Zassenhaus scheme.

In the substitution and permutation according to the present invention, the required memory capacity and the computational complexity can be reduced by rearranging rows of the matrix P based on the same components of the permutation matrix P or the same substituted components s_(j)(x).

According to the permutation method of the present invention, the computational complexity can be reduced by expressing the current permuted data using the preceding permuted data and the difference between the current and the previous permuted data.

Appendix Proof of Inverse Algorithm

1. Preparation

Letting C be a natural number and n be a natural number equal to or greater than 1, $C = {c_{0} + {\sum\limits_{i = 1}^{n}\quad {c_{i}2^{2^{i - 1}}}}}$

In the following each variable has a bit size of 2^(n); therefore, mod² ^(n) will be omitted unless any particular problems arise. In principle, numbers themselves will be written in uppercase alphabetic characters and individual digits in the development will be in lower-case alphabetic characters (with some exceptions).

Algorithm 1 is shown below:

modinv1(X) { a₀ = x₀ ⁻¹mod2; B₀ = [Xa₀mod2² ^(n) /2]; Y₀ = a₀; for(i = 0;i ≦ n − 1;i ++){ β_(i) = B_(i)mod2² ^(i) ; a_(i+1) = −β_(i)Y_(i)mod2² ^(i) ; Y_(i+1) = Y₁ + a_(i+1) × 2² ^(i) ; B_(i+1) = [(Xa_(i+1) + B_(i))mod2² ^(n−2i) /2² ^(i) ]; } return(Y_(n)); }

Proposition 1.1([1]): If input X of Algorithm 1 meets the conditions 0<X<2² ^(n) and (X, 2² ^(n) )=1, then return value Y₂ will satisfy

XY _(n)≡1(mod2² ^(n) )

To prove this proposition, the following lemmas will be discussed first.

Lemma 1.1: For i≧0, B_(i)=[XY_(i)mod2² ^(n) /2² ^(i) ].

Proof. For i=0, the statement is clear. For each k≧0 assume that the following equation holds:

XY _(k) =B _(k)2^(2k) +R (0<R<2² ^(k) )  (1)

For i=k,

z=[x/y]x=yz+xmody  (2)

is used to obtain

(Xa _(k+1) +B _(k))mod2² ^(n) ⁻² ^(k) =B _(k+1)2² ^(k) +(Xa _(k+1) +B _(k))mod2² ^(k)

Multiplying the both sides by 2² ^(k) , we have

2² ^(k) (Xa _(k+1) +B _(k))mod2² ^(n) =B _(k+1)2² ^(k+1) +2² ^(k) (Xa _(k+1) +B _(k))mod2² ^(k+1)   (3)

It follows from Eq. (1) that

XY _(k+1) =X(a _(k+1)2² ^(k) +Y _(k))=2² ^(k) (Xa _(k+1) +B _(k))+R

Substitution of this into Eq.(3) gives

(XY _(k+1) −R)mod2² ^(n) =B _(k+1)2² ^(k+1) +(XY _(k+1) −R)mod2² ^(k+1)   (4)

Since 0<R<2² ^(k) , we have

XY _(k+1)mod2² ^(n) −R=B _(k+1)2² ^(k+1) +XY _(k+1)mod2² ^(k+1) −R

and eliminate R from either side. Noting that

(XY _(k+1)mod2² ^(n) )mod2² ^(k+1) =XY _(k+1)mod2² ^(k+1)

the use of Eq. (2) gives $B_{k + 1} = \left\lbrack \frac{{XY}_{k + 1}{mod}\quad 2^{2^{n}}}{2^{2^{k + 1}}} \right\rbrack$

(Q.E.D.)

Next, the proposition will be proved.

Proof. It is sufficient to prove that XY_(i)=1mod2² ^(i) for each i. For i=0. the answer is evident from the algorithm. For each k≧0 assume that the statement is true for i=k. For i=k+1, we have $\begin{matrix} {{{XY}_{k + 1}{mod}\quad 2^{2^{k + 1}}} = {{X\left( {{a_{k + 1}2^{2^{k}}} + Y_{k}} \right)}\quad {mod}\quad 2^{2^{k + 1}}}} \\ {= {\left( {{{X\left( {{- \beta_{k}}Y_{k}{mod}\quad 2^{2^{k}}} \right)}2^{2^{k}}} + Y_{k}} \right)\quad {mod}\quad 2^{2^{k + 1}}}} \\ {= {{\left( {{- X}\quad \beta_{k}Y_{k}\quad {mod}\quad 2^{2^{k}}} \right)2^{2^{k}}} + {{XY}_{k}\quad {mod}\quad 2^{2^{k + 1}}}}} \end{matrix}$

We have XY_(k)=1mod2² ^(k) using the induction hypothesis, and (B_(k)mod2² ^(k) )2² ^(k) =β_(k)2² ^(k) using B_(k)[XY_(k)mod2² ^(n) /2² ^(k) ] from the lemma. Therefore, XY_(k)mod2² ^(k+1) =β_(k)2² ^(k) +1 holds. Finally we obtain $\begin{matrix} {{{{XY}_{k + 1}{mod}\quad 2^{2^{k + 1}}} = {{\left( {{- X}\quad \beta_{k}Y_{k}{mod}\quad 2^{2^{k}}} \right)2^{2^{k}}} + {\beta_{k}2^{2^{k}}} + 1}}\quad} \\ {= {{\left( {\left( \quad {\beta_{k}\left( {1 - {XY}_{k}} \right)} \right)\quad {mod}\quad 2^{2^{k}}} \right)2^{2^{k}}} + 1}} \\ {= {{\left( {\left( \quad {\beta_{k}\left( {1 - 1} \right)} \right)\quad {mod}\quad 2^{2^{k}}} \right)2^{2^{k}}} + 1}} \\ {= 1} \end{matrix}$

2. Algorithm 2

Algorithm 2 is shown below:

modinv2(X) { B₀ = [X/2]; A₁ = B₀ & 1; B₁ = [(XA₁ + B₀)/2]; Y₁ = B₁ & 3; for(i = 1;i ≦ n − 1:i ++){ A_(i+1) = −B_(i)Y_(i); B_(i+1) = [(XA_(i+1) + B_(i))/2² ^(i) ]; Y_(i+1) = Y_(i) + A_(i+1) × 2² ^(i) : } return(Y_(n)); }

Theorem 2.1: If the input X of algorithm 2 meets the condition0<X<2² ^(n) and (X, 2² ^(n) )=1, return value Y_(n) will satisfy:

XY _(n)≡1(mod2² ^(n) )

Proof. Algorithm 2 is a modified version of Algorithm 1, and several modular arithmetics are omitted. Accordingly, the value of each variable of the algorithm is free from modular arithmetic, and hence it has some value (garbage) added to the value in Algorithm 1. The value in Algorithm 1, for example, the variable X will hereinafter be described as X⁽⁰⁾. For instance, Y₂ in Algorithm 1 is denoted by Y₂ ⁽⁰⁾, and the garbage is denoted by C and expressed by Y₂=Y₂ ⁽⁰⁾+C. Note that the discussion on Algorithm 1 holds if every variable is described as X⁽⁰⁾.

For i≧1, it will be proved by induction that the following mathematical expressions hold in Algorithm 2:

C _(i)=0mod2² ^(i−1)   (5)

$\begin{matrix} {B_{i} = {B_{i}^{(0)} + {X \times \frac{C_{i}}{2^{2^{i - 1}}}}}} & (6) \end{matrix}$

 Y _(i) =Y _(i) ⁽⁰⁾ +C _(i)×2² ^(i−1)   (7)

Each C_(i) is the afore-mentioned “garbage,” which is at least a multiple of 2² ^(i−1) . B_(i) and Y_(i) have added thereto C_(i) in the above form.

When i=1, each of A₁, B₁, Y₁ is a processing equivalent to Algorithm 1, and hence no “garbage” exists. Accordingly, C₁=0, and Eqs. (5), (6) and (7) hold.

For each k≧1 assume that Eqs. (5), (6) and (7) hold for i=k. For i=k+1, we will show that Y_(k+1) satisfies Eq. (7). To begin with,

A _(k+1) =−B _(k) Y _(k)

is calculated. As the calculation continues, we have $\begin{matrix} {A_{k + 1} = {{- \left( {B_{k}^{(0)} + \frac{{XC}_{k}}{2^{2^{k - 1}}}} \right)}\quad \left( {Y_{k}^{(0)} + {C_{k} \times 2^{2^{k - 1}}}} \right)}} \\ {= {{{- B_{k}^{(0)}}Y_{k}^{(0)}} - \frac{Y_{k}^{(0)}{XC}_{k}}{2^{2^{k - 1}}} - {B_{k}^{(0)}C_{k} \times 2^{2^{k - 1}}} - {{XC}_{k}C_{k}}}} \\ {= {a_{k + 1}^{(0)} + D_{k + 1} - \frac{Y_{k}^{(0)}{XC}_{k}}{2^{2^{k - 1}}} - {B_{k}^{(0)}C_{k} \times 2^{2^{k - 1}}} - {{XC}_{k}C_{k}}}} \end{matrix}$

From Algorithm 1,

a _(k+1) ⁽⁰⁾=−β_(k) Y _(k)mod2² ^(k) =−B _(k) Y _(k)mod2² ^(k) and

D _(k+1) =[B _(k) Y _(k)/2² ^(k) ]×2² ^(k)

That is, low-order 2^(k) bit portion of −B_(k)Y_(k) is expressed by a_(k+1) ⁽⁰⁾, and the high order is expressed by D_(k+1). Note that D_(k+1) is D_(k+1)=0 mod 2² ^(k) like C_(k). From the above, we have $\begin{matrix} {Y_{k + 1} = \quad {Y_{k} + {A_{k + 1} \times 2^{2^{k}}}}} \\ {= \quad {Y_{k}^{(0)} + {C_{k} \times 2^{2^{k - 1}}} +}} \\ {\quad {\left( {a_{k + 1}^{(0)} + D_{k + 1} - \frac{Y_{k}^{(0)}{XC}_{k}}{2^{2^{k - 1}}} - {B_{k}^{(0)}C_{k} \times 2^{2^{k - 1}}} - {{XC}_{k}C_{k}}} \right) \times 2^{2^{k}}}} \\ {= \quad {Y_{k}^{(0)} + {a_{k + 1}^{(0)} \times 2^{2^{k}}} +}} \\ {\quad {\left( {\frac{C_{k}}{2^{2^{k - 1}}} + D_{k + 1} - \frac{Y_{k}^{(0)}{XC}_{k}}{2^{2^{k - 1}}} - {B_{k}^{(0)}C_{k} \times 2^{2^{k - 1}}} - {{XC}_{k}C_{k}}} \right) \times 2^{2^{k}}}} \\ {= \quad {Y_{k + 1}^{(0)} +}} \\ {\quad {\left( {\frac{C_{k}}{2^{2^{k - 1}}} + D_{k + 1} - \frac{Y_{k}^{(0)}{XC}_{k}}{2^{2^{k - 1}}} - {B_{k}^{(0)}C_{k} \times 2^{2^{k - 1}}} - {{XC}_{k}C_{k}}} \right) \times 2^{2^{k}}}} \end{matrix}$

Now, set $C_{k + 1} = {\left( {\frac{C_{k}}{2^{2^{k - 1}}} + D_{k + 1} - \frac{Y_{k}^{(0)}{XC}_{k}}{2^{2^{k - 1}}} - {B_{k}^{(0)}C_{k} \times 2^{2^{k - 1}}} - {{XC}_{k}C_{k}}} \right)\quad {mod}\quad 2^{2^{n} - 2^{k}}}$

Since each of individual variables has a bit size of 2^(n) and since the second term on the right-hand side of the above has been multiplied by 2² ^(k) , we see that even if C_(k+1) is calculated under modulo 2² ^(n) ⁻² ^(k) , the following equation holds:

Y _(k+1) =Y _(k+1) ⁽⁰⁾ +C _(k+1)×2² ^(k)   (8)

Next we will show that C_(k+1) satisfies Eq. (5), that C_(k+1) satisfied Eq. (5), that is, C_(k+1) is a multiple of 2² ^(k) . Since C_(k)=0 mod 2² ^(k−1) , it is clear that XC_(k)C_(k)=0 mod 2² ^(k) and that B_(k) ⁽⁰⁾C_(k)×2² ^(k−i) =0 mod 2² ^(k) . And, as mentioned previously, D_(k+1)=0 mod 2² ^(k) . Now, ${\frac{C_{k}}{2^{2^{k - 1}}} - \frac{Y_{k}^{(0)}{XC}_{k}}{2^{2^{k - 1}}}} = {\frac{C_{k}}{2^{2^{k - 1}}}\left( {1 - {Y_{k}^{(0)}X}} \right)}$

but since XY_(k) ⁽⁰⁾=1 mod 2² ^(k) from the lemma, we have

(1−Y _(k) ⁽⁰⁾ X)=0mod2² ^(k)

Using C_(k)=0mod2² ^(k−1) , we have ${\frac{C_{k}}{2^{2^{k - 1}}}\left( {1 - {Y_{k}^{(0)}X}} \right)} = {0\quad {mod}\quad {2^{2^{k}}.}}$

Thus it is proved that

C _(k+1)=0 mod 2² ^(k)   (9)

From the above we find that Eqs. (5) and (7) hold also when i=k+1. If it is shown using this C_(k+1) that when i=k+1, B_(k+1) satisfies Eq. (6), then the theorem will be proved. Now, from Algorithm 2, B_(k+1) becomes as follows:

B _(k+1)=[(XA _(k+1) +B _(k))/2² ^(k) ]

Using Eq. (2) the above equation can be modified as follows:

XA _(k+1) B _(k) =B _(k+1)×2² ^(k) +(XA _(k+1) +B _(k))mod2² ^(k)

Since the bit size of each variable is 2^(n), and since B_(k+1) is multiplied by 2² ^(k) , there exist no problem even if the both sides are calculated under modulo 2² ^(n) ⁻² ^(k) . Accordingly, we have

(XA _(k+1) B _(k))mod2² ^(n) ⁻² ^(k) B _(k+1)×2² ^(k) +(XA _(k+1) +B _(k))mod2² ^(k)   (10)

Then we have $\begin{matrix} {{{XA}_{k + 1} + B_{k}} = \quad {{X\left( {a_{k + 1}^{(0)} + D_{k + 1} - \frac{Y_{k}^{(0)}{XC}_{k}}{2^{2^{k - 1}}} - {B_{k}^{(0)}C_{k} \times 2^{2^{k - 1}}} - {{XC}_{k}C_{k}}} \right)} +}} \\ {\quad {B_{k}^{(0)} + {X \times \frac{C_{k}}{2^{2^{k - 1}}}}}} \\ {= \quad {{Xa}_{k + 1}^{(0)} + B_{k}^{(0)} +}} \\ {\quad {X\left( {\frac{C_{k}}{2^{2^{k - 1}}} + D_{k + 1} - \frac{Y_{k}^{(0)}{XC}_{k}}{2^{2^{k - 1}}} - {B_{k}^{(0)}C_{k} \times 2^{2^{k - 1}}} - {{XC}_{k}C_{k}}} \right)}} \end{matrix}$

Hence the left-hand side of Eq. (10) becomes as follows:

(XA _(k+1) +B _(k))mod2² ^(n) ⁻² ^(k) =(Xa _(k+1) ⁽⁰⁾ +B _(k) ⁽⁰⁾)mod2² ^(n) ⁻² ^(k) +XC _(k+1)

Furthermore, using Eq. (9), the second term on the right-hand side of Eq. (10) becomes as follows: $\begin{matrix} {{\left( {{XA}_{k + 1} + B_{k}} \right){mod}\quad 2^{2^{k}}} = {\left( {{Xa}_{k + 1}^{(0)} + B_{k}^{(0)} + C_{k + 1}} \right){mod}\quad 2^{2^{k}}}} \\ {= {\left( {{Xa}_{k + 1}^{(0)} + B_{k}^{(0)}} \right){mod}\quad 2^{2^{k}}}} \end{matrix}$

Therefore, we have

Xa _(k+1) ⁽⁰⁾ +B _(k) ⁽⁰⁾)mod2² ^(n) ⁻² ^(k) +XC _(k+1) =B _(k+1)×2² ^(k) +(Xa _(k+1) ⁽⁰⁾ +B _(k) ⁽⁰⁾)mod2² ^(k)

and ${\left( {{Xa}_{k + 1}^{(0)} + B_{k}^{(0)}} \right){mod}\quad 2^{2^{n} - 2^{k}}} = {{\left( {B_{k + 1} - {X\quad \frac{C_{k + 1}}{2^{2^{k}}}}} \right) \times 2^{2^{k}}} + {\left( {{Xa}_{k + 1}^{(0)} + B_{k}^{(0)}} \right){mod}\quad 2^{2^{k}}}}$

And the following equation holds: ${B_{k + 1} - {X\quad \frac{C_{k + 1}}{2^{2^{k}}}}} = {\left\lbrack {\left( {{Xa}_{k + 1}^{(0)} + B_{k}^{(0)}} \right)\quad {mod}\quad {2^{2^{n} - 2^{k}}/2^{2^{k}}}} \right\rbrack = B_{k + 1}^{(0)}}$

Thus the following is proved: $\begin{matrix} {B_{k + 1} = {B_{k + 1}^{(0)} + {X\quad \frac{\quad C_{k + 1}}{2^{2^{k}}}}}} & (11) \end{matrix}$

From the above, Eqs. (5), (6) and (7) hold also when i=k+1.

For i=n, since the “garbage” C_(n)×2² ^(n) becomes a multiple of 2² ^(k) ,and each variables has a bit size of 2^(2n), we obtain Y_(n)=Y_(n) ⁽⁰⁾; from the proposition

XY _(n)=1mod2² ^(n)

holds. Thus the proposition is proved. (Q.E.D.)

Reference

[1] Kawamura, “New algorithms for inverse module a prime power,” SCIS'97-14C. 

What is claimed is:
 1. A substitution-permutation apparatus which, by the following substitution-permutation over a ring R $\begin{bmatrix} y_{1} \\ y_{2} \\ \vdots \\ y_{m} \end{bmatrix} = {P\begin{bmatrix} {s_{1}\left( x_{1} \right)} \\ {s_{2}\left( x_{2} \right)} \\ \vdots \\ {s_{n}\left( x_{n} \right)} \end{bmatrix}}$

where $P = \begin{bmatrix} p_{11} & p_{12} & \cdots & p_{1n} \\ p_{21} & p_{22} & \quad & p_{2n} \\ \vdots & \quad & \quad & \vdots \\ p_{m1} & p_{m2} & \cdots & p_{mn} \end{bmatrix}$

 p _(ij) εR, s _(j) :R→R i=1, 2, . . . , m j=1, 2, . . . , n  performs a substitution-permutation operation of an input data sequence (x_(j)) to calculate a data sequence (y_(i)), said apparatus comprising: storage means for storing: precalculated values of v_(i) (whose dimensions are up to m and may differ individually) over said ring R necessary for said substitution-permutation, obtained by swapping rows or columns of said matrix P for which some of p_(ij) or s_(j) are the same values; a precalculated value of a function S_(k):R→R^(m); precalculated values of n vectors w_(k)εR^(m); and an integer k; input means for storing said input data sequence (x_(j)) in said storage means; k-initialization means for setting said integer k to 0; k-updating means for updating said k in said storage means to k+1; S_(k) calculating means for reading out each S_(k) and input data (x_(k)) from said storage means to obtain the result of calculation of a vector S_(k) (x_(k)) and for storing said vector as a vector w_(k) in said storage means; means for reading out of said storage means a set of vectors {v₁} necessary for forming a k-th column of said matrix P and for generating a vector u_(k); u_(k)*S_(k) calculating means for reading out said w_(k) from said storage means and calculating the product for each element and for updating said w_(k) with the calculation result; control means for reading out said k stored in said storage means and for actuating said S_(k) calculating means, said u_(k)*S_(k) calculating means and said k-updating means one after another until k=n; and output means for reading out each w_(k) stored in said storage means and for calculating and outputting their sum.
 2. A substitution-permutation apparatus which, by the following substitution-permutation over a ring R $\begin{bmatrix} y_{1} \\ y_{2} \\ \vdots \\ y_{m} \end{bmatrix} = {P\begin{bmatrix} {s_{1}\left( x_{1} \right)} \\ {s_{2}\left( x_{2} \right)} \\ \vdots \\ {s_{n}\left( x_{n} \right)} \end{bmatrix}}$

where $P = \begin{bmatrix} p_{11} & p_{12} & \cdots & p_{1n} \\ p_{21} & p_{22} & \quad & p_{2n} \\ \vdots & \quad & \quad & \vdots \\ p_{m1} & p_{m2} & \cdots & p_{mn} \end{bmatrix}$

 p _(ij) εR, s _(j) :R→R i=1, 2, . . . , m j=1, 2, . . . , n performs a substitution-permutation operation of an input data sequence (X_(j)) to calculate a data sequence (y_(i)), said apparatus comprising: storage means for storing: a precalculated value of the following equation with rows of a matrix P rearranged ${{SP}_{lj}\left( x_{j} \right)} = \begin{bmatrix} {p_{{t{({ql})}}j}{s_{j}\left( x_{j} \right)}} \\ {p_{{t{({{ql} + 1})}}j}{s_{j}\left( x_{j} \right)}} \\ \vdots \\ {p_{{t{({rl})}}j}{s_{j}\left( x_{j} \right)}} \end{bmatrix}$

where b(j) is a natural number equal to or greater than 1 but equal to or smaller than n, 1=1,2, . . . ,b(j), t:{1, 2, . . . , m}→{ 1, 2, .. ., m} is a permutation, and ql and rl are natural numbers greater than 1 but smaller than m+1, where ql≦rl; precalculated values of n vectors w_(k)εR^(m); and an integer k; input means for storing said input data sequence (x_(j)) in said storage means; k-initialization means for setting said integer k to 0; k-updating means for updating said k stored in said storage means to k+1; SP_(k) calculating means for reading out input data x_(k) and SP_(lj)(x_(k)) from said storage means, for calculating said SP_(lj)(x_(k)) for each l and concatenating the calculated results in correspondence to a k-th column of said rearranged matrix P to obtain an m-dimensional vector, and for updating said w_(k) stored in said storage means with said m-dimensional vector as w_(k), where l=1, 2, . . . , b(j); control means for reading out said k stored in said storage means and for actuating said SP_(k) calculating means and said k-updating means one after the other until k=n; and output means for reading out each w_(k) stored in said storage means and for calculating and outputting their sum.
 3. The apparatus of claim 2, further including shift operation means for shifting a column vector of said read-out vectors SP_(k)(x_(i)) in the column direction to update said w_(k) stored in said storage means.
 4. The apparatus of claim 2, further comprising: means for obtaining a sum vector by calculating the sum of some of said read-out vectors SP_(lj)(x_(k)); means for obtaining a plurality of column vectors by shifting in different column directions a partial sum vector obtained in the course of calculating said sum vector; means for obtaining an added vector by adding said plurality of column vectors and said sum vector; and means for concatenating said added vector and said sum vector into an m-dimensional vector.
 5. The apparatus of claim 2, further comprising: means for obtaining a sum vector by calculating the sum of some of said read-out vectors SP_(lj)(x_(k)); means for obtaining a column vector by rotating in the column direction a partial sum vector obtained in the course of calculating said sum vector; means for obtaining an added vector by adding said column vector and said sum vector; and means for concatenating said added vector and said sum vector into an m-dimensional vector.
 6. A recording medium having recorded thereon a program for the execution by a computer of a substitution-permutation apparatus which, by the following substitution-permutation over a ring R $\begin{bmatrix} y_{1} \\ y_{2} \\ \vdots \\ y_{m} \end{bmatrix} = {P\begin{bmatrix} {s_{1}\left( x_{1} \right)} \\ {s_{2}\left( x_{2} \right)} \\ \vdots \\ {s_{n}\left( x_{n} \right)} \end{bmatrix}}$

where $P = \begin{bmatrix} p_{11} & p_{12} & \cdots & p_{1n} \\ p_{21} & p_{22} & \quad & p_{2n} \\ \vdots & \quad & \quad & \vdots \\ p_{m1} & p_{m2} & \cdots & p_{mn} \end{bmatrix}$

 p _(ij) εR, s _(j) :R→R i=1, 2, . . . , m j=1, 2, . . . , n performs a substitution-permutation operation of an input data sequence (x_(j)) to calculate a data sequence (y_(i)) and in which storage means has stored therein: precalculated values of v_(i) (whose dimensions are up to m and may differ individually) over said ring R necessary for said substitution-permutation, obtained by swapping rows or columns of said matrix P for which some of p_(ij) or s_(j) are the same values; a precalculated value of a function S_(k):R→R^(m); precalculated values of n vectors w_(k)εR^(m); and an integer k; said program comprising the steps of: (a) storing said input data sequence x_(j) in said storage means; (b) initializing said integer k to 0; (c) updating said k in said storage means to k+1; (d) reading out each S_(k) and input data (x_(k)) from said storage means to obtain the result of calculation of a vector S_(k) (x_(k)) and storing said vector as a vector w_(k) in said storage means; (e) reading out of said storage means a set of vectors {v₁} necessary for forming a k-th column of said matrix P and generating a vector u_(k); (f) reading out said w_(k) from said storage means and calculating the product for each element and updating said w_(k) with the calculation result; (g) reading out said k stored in said storage means and performing said S_(k) calculating step, said w_(k) updating steps and said k-updating step one after another until k=n; and (h) reading out each w_(k) stored in said storage means and calculating; and outputting their sum.
 7. A recording medium having recorded thereon a program for the execution by a computer of a substitution-permutation apparatus which, by the following substitution-permutation over a ring R $\begin{bmatrix} y_{1} \\ y_{2} \\ \vdots \\ y_{m} \end{bmatrix} = {P\begin{bmatrix} {s_{1}\left( x_{1} \right)} \\ {s_{2}\left( x_{2} \right)} \\ \vdots \\ {s_{n}\left( x_{n} \right)} \end{bmatrix}}$

where $P = \begin{bmatrix} p_{11} & p_{12} & \cdots & p_{1n} \\ p_{21} & p_{22} & \quad & p_{2n} \\ \vdots & \quad & \quad & \vdots \\ p_{m1} & p_{m2} & \cdots & p_{mn} \end{bmatrix}$

 p _(ij) εR, s _(j) :R→R i=1, 2, . . . , m j=1, 2, . . . , n performs a substitution-permutation operation of an input data sequence (x_(j)) to calculate a data sequence (y_(i)) and in which storage means has recorded therein a precalculated value of the following equation with rows of a matrix P rearranged ${{SP}_{lj}\left( x_{j} \right)} = \begin{bmatrix} {p_{{t{({ql})}}j}{s_{j}\left( x_{j} \right)}} \\ {p_{{t{({{ql} + 1})}}j}{s_{j}\left( x_{j} \right)}} \\ \vdots \\ {p_{{t{({rl})}}j}{s_{j}\left( x_{j} \right)}} \end{bmatrix}$

where b(j) is a natural number equal to or greater than 1 but equal to or smaller than n, l=1,2, . . . ,b(j), t: {1, 2, . . . , m}→{1, 2, . . . , m} is a permutation, and ql and rl are natural numbers equal to or greater than 1 but equal to or smaller than m, where ql≦rl, together with; precalculated values of n vectors w_(k)εR^(m) and an integer k, said program comprising the steps of; (a) storing said input data sequence (x_(j)) in said storage means; (b) initializating said integer k to 0; (c) updating said k stored in said storage means to k+1; (d) reading out input data x_(k) from said storage means, calculating SP_(lj)(x_(k)) for each l, concatenating the calculated results in correspondence to a k-th column of said rearranged matrix P to obtain an m-dimensional vector, and updating said w_(k) stored in said storage means with said m-dimensional vector as w_(k), where l=1, 2, . . . , b(j); (e) reading out said k stored in said storage means and performing said SP_(k) calculating step and said k-updating step one after the other until k=n; and (f) reading out each w_(k) stored in said storage means and calculating and outputting their sum.
 8. The recording medium of claim 7, wherein said program further comprises the step of shifting the column vector of said read-out vector SP_(k)(x_(i)) in the column direction to update said w_(k) stored in said storage means.
 9. The recording medium of claim 7, wherein said program further comprises the steps of: obtaining a sum vector by calculating the sum of some of said read-out vectors SP_(lj)(x_(k)); obtaining a plurality of column vectors by shifting in different column directions a partial sum vector obtained in the course of calculating said sum vector; obtaining an added vector by adding said plurality of column vectors and said sum vector; and concatenating said added vector and said sum vector into an m-dimensional vector.
 10. The recording medium of claim 7, wherein said program further comprises the steps of: (g) obtaining a sum vector by calculating the sum of some of said read-out vectors SP_(lj)(x_(k)); (h) obtaining a column vector by rotating in the column direction a partial sum vector obtained in the course of calculating said sum vector; (i) obtaining an added vector by adding said column vector and said sum vector; and (j) concatenating said added vector and said sum vector into an m-dimensional vector. 